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

fix #10053: FieldError exception messages now show discriminant + type #11951

Merged
merged 1 commit into from
Aug 15, 2019

Conversation

timotheecour
Copy link
Member

@timotheecour timotheecour commented Aug 14, 2019

type Kind = enum k1, k2

type Foo = object
  case kind: Kind
  of k1:
    f1: int
  of k2:
    f2: int

proc main()=
  var foo = Foo()
  echo foo.f2
main()

before PR:
Error: unhandled exception: f2 [FieldError]

in most cases (eg see error msg i got from #11947) this is not very helpful

after PR:
Error: unhandled exception: 'f2' is not accessible using discriminant 'kind' of type 'Foo' [FieldError]

works with nim js and nim c

note

I have another PR to fix the VM case, but it depends on this PR so i'll wait until this is merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better FieldError exception messages
2 participants