简体   繁体   中英

Valid Hy Code throws an unexpected end of input error?

this is an exert of the code foor a game that I am writing.

(for [sprite self.sprites]
      (if (!= (type sprite.content) NoneType)
          (sprite.content.render)))

it complains about a parse error for pattern macro 'if': got unexpected end of input, expected: some(...) , even though thus IS valid Hy code.

Ran with both Hy version 0.25.0 on PyPy, 0.24.0 and 0.25.0 on CPython. Still threw the same error. The code should not have thrown the error at all, because it was working perfectly fine yesterday, I come back today and it'd throw an error, despite no changes.

This is not, in fact, valid Hy code. As suggested by the error message, if requires a third argument. See the manual entry on if .

As for how this code could've been "working perfectly fine yesterday", I have no explanation, unless you were using a different version of Hy yesterday.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM