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

FieldError exception messages for generics #17148

Open
mratsim opened this issue Feb 22, 2021 · 2 comments
Open

FieldError exception messages for generics #17148

mratsim opened this issue Feb 22, 2021 · 2 comments

Comments

@mratsim
Copy link
Collaborator

mratsim commented Feb 22, 2021

Following #10053 and #11951, field error messages has been improved.

For generics, however the generic type isn't reported:

type Result[T, E] = object
  case ok: bool
  of false:
    error: E
  of true:
    value: T

proc main()=
  var foo = Result[int, cstring]()
  echo foo.value

main()

Error

Error: unhandled exception: 'value' is not accessible using discriminant 'ok' of type 'Result' [FieldError]
@timotheecour
Copy link
Member

can you clarify the issue by adding what you expect the compiler to output? I'm assuming it'd be:

Error: unhandled exception: 'value' is not accessible using discriminant 'ok' of type 'Result[int, cstring]' [FieldError]

?

see also #11955 which I need to update (related but different from this issue)

@mratsim
Copy link
Collaborator Author

mratsim commented Feb 22, 2021

Yes, the full instantiated type Result[int, cstring]

The better error message would be:

Error: unhandled exception: 'value' is not accessible using discriminant 'ok' of type 'bool' in variant object of type 'Result[int, cstring]' [FieldError]

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

No branches or pull requests

2 participants