Operator "or" in converter types seems to crash the compiler. #4537

Closed
oderwat opened this Issue Jul 29, 2016 · 0 comments

Projects

None yet

1 participant

@oderwat
Contributor
oderwat commented Jul 29, 2016 edited

Using a converter like in the example below crashes with SIGSEV when trying to compile with the Javascript backend:

# nim js --d:nodejs

type
  Str = distinct string

when true:
  # crashes
  converter convert(s: string | cstring): Str = Str($s)
else:
  # works!
  converter convert(s: string): Str = Str($s)
  converter convert(s: cstring): Str = Str($s)

proc echoStr(s: Str) = echo s.string

echoStr("test")
echoStr("test".cstring)

Trying to compile it with the C backend gives:

simple_crash.nim(7, 21) Error: internal error: metatype not eliminated

@oderwat oderwat closed this Jul 29, 2016
@oderwat oderwat changed the title from Operator "or" in converters types seem to crash the compiler. to Operator "or" in converter types seems to crash the compiler. Jul 29, 2016
@oderwat oderwat reopened this Jul 29, 2016
@Araq Araq added a commit that closed this issue Aug 2, 2016
@Araq Araq fixes #4537 4d5c002
@Araq Araq closed this in 4d5c002 Aug 2, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment