Annotate custom check function as assert #3418
Unanswered
sewbacca
asked this question in
Annotation Authoring
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It is sometimes nice to do some checks on variables such as:
Note the separation of those two lines, in real code those might be much further apart. Also
---@param notoptional table?is for demonstration purposes only, the value might come from another function call.This works fine, but when I want to implement a custom assert function:
This does no longer work. The annotation for
utils.assertis basically the same as for assert:This works fine for assignments, but assert delivers more information, i.e. implicit casting of variables. It would be nice if there were something like
---@special <varname>. I could use"runtime.special": { "check": "assert" }and makeutils.checkglobal, but that is ugly. Is there another workarround?Beta Was this translation helpful? Give feedback.
All reactions