You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve compile time inspection and catch wrong usage of variant object at compile time.
Currently compiler fails to catch that bug and it causes runtime exception.
Additional Information
This code should fail at compile time, not runtime
type
DocKind = enum
text,
todo
Doc = object
case kind: DocKind
of text:
text: string
of todo:
todo: string
let doc = Doc(kind: text, text: "some doc")
echo doc.text
echo doc.todo # <= bug, should be caught at compile time
The text was updated successfully, but these errors were encountered:
There is a ProveField warning for this (e.g. --warning:ProveField:on --warningAsError:ProveField). But it does not work very well, see e.g. #7882. In your case it is triggered on both doc.text and doc.todo :-(.
Summary
Improve compile time inspection and catch wrong usage of variant object at compile time.
Currently compiler fails to catch that bug and it causes runtime exception.
Additional Information
This code should fail at compile time, not runtime
The text was updated successfully, but these errors were encountered: