[英]Requiring `hy' macro with `raise' function triggers `raise' on `require'
When trying to require
the following macro in another file, the raise
seems to be triggering immediately:当试图在另一个文件中
require
以下宏时, raise
似乎会立即触发:
(defmacro assert [a [b True] [message None]]
`(unless (= ~a ~b) (raise (AssertionError (or ~message ~a)))))
This results in an AssertionError: True
.这会导致
AssertionError: True
。
Steps to reproduce (sometimes works, and sometimes doesn't):重现步骤(有时有效,有时无效):
echo '(defmacro assert [a [b True] [message None]] `(unless (= ~a ~b) (raise (AssertionError (or ~message ~a)))))' > a.hy
echo '(require a [assert])' > b.hy
echo '(assert True)' >> b.hy
hy b.hy
In another instance of Python evaluating function arguments before names, as stated by Kodiologist in their comment here and their answer on one of my previous questions "Non-existent hy macros runs assertions, but fails appropriately with everything else" , the issue was that unless
didn't trigger a NameError
when it didn't exist, since it was moved from the hy
core to hyrule
a little over a year ago. In another instance of Python evaluating function arguments before names, as stated by Kodiologist in their comment here and their answer on one of my previous questions "Non-existent hy macros runs assertions, but fails appropriately with everything else" , the issue was that
unless
当NameError
不存在时并没有触发它,因为它在一年前从hy
核心转移到了hyrule
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.