Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal error when using typedesc `is` comparison in a macro #10136

Closed
bluenote10 opened this issue Dec 30, 2018 · 4 comments

Comments

Projects
None yet
6 participants
@bluenote10
Copy link
Contributor

commented Dec 30, 2018

The following errors with internal error: (filename: "semexprs.nim", line: 406, column: 19):

import macros

macro toGodotName(T: typedesc) =
  if T is string:
    echo "string"
  else:
    echo "not string"

The same works fine when using proc instead of macro.

This is most likely a regression, because the example is taken from the nim godot bindings, which used to work with 0.18. Is this still supposed to work with 0.19+?

@nc-x

This comment has been minimized.

Copy link
Contributor

commented Dec 30, 2018

Regression due to #8723 cc @LemonBoy

@nc-x

This comment has been minimized.

Copy link
Contributor

commented Dec 30, 2018

Also note that the stacktrace is wrong -
pragmagic/godot-nim#42 (comment)
Relevant lines -

semexprs.nim(2013)       semMagic
msgs.nim(545)            semIs
msgs.nim(538)            internalError
@LemonBoy

This comment has been minimized.

Copy link
Contributor

commented Jan 12, 2019

Oh well, the assertion can be safely (?) replaced by something like:

if lhsType.base.kind == tyNone:
  return

(maybe just checking lhsType.containsGenericType if the lhs is a typedesc may be enough since you can't do much at this stage)

This way the is operator is resolved by the VM using a shitty isOpImpl approximation (the PR that introduced this regression killed a third variant of the same algorithm, scientists are still not 100% sure we know how many more are left in the wild).

Cheers

@Clyybber

This comment has been minimized.

Copy link
Contributor

commented Jan 13, 2019

Yay, @LemonBoy is back! :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.