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

Regression: compile error using when/elif/else and typedesc in template #19426

Closed
arkanoid87 opened this issue Jan 20, 2022 · 0 comments · Fixed by #20550
Closed

Regression: compile error using when/elif/else and typedesc in template #19426

arkanoid87 opened this issue Jan 20, 2022 · 0 comments · Fixed by #20550

Comments

@arkanoid87
Copy link
Contributor

Please help me find a better title for this issue.

The example compiles with 1.4.8 and returns error with 1.6.0.
Bisect has found 2aba116 as first bad commit

Tested with both orc and refc

https://play.nim-lang.org/#ix=3MTf

Example

type
  MyInt = object
    bitWidth: int

template toRealType*(t: MyInt): typedesc =
  when t.bitWidth == 32: int32
  elif t.bitWidth == 64: int64
  else: {.error.}

proc doFail(T: typedesc): T = default(T)

proc test =
  const myInt = MyInt(bitWidth:32)
  discard doFail(toRealType(myInt))

test()

Current Output

Error: unhandled exception: field 'sym' is not accessible for type 'TNode' using 'kind = nkIdent' [FieldDefect]

Expected Output

compilation successful

Additional Information

It's a regression:

  • 1.4.8: compiles successfully
  • 1.6.0 up to devel: compilation error

Bisect result

first bad commit: [2aba116] when statements branches exit early (#17143)

bung87 added a commit to bung87/Nim that referenced this issue Oct 12, 2022
bung87 added a commit to bung87/Nim that referenced this issue Oct 13, 2022
capocasa pushed a commit to capocasa/Nim that referenced this issue Mar 31, 2023
narimiran pushed a commit that referenced this issue Apr 25, 2023
narimiran pushed a commit that referenced this issue Apr 25, 2023
narimiran pushed a commit that referenced this issue Apr 25, 2023
bung87 added a commit to bung87/Nim that referenced this issue Jul 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants