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
The checker rejects a comptime-guarded val == unsafe { nil } comparison when val has type ?&T, even though the $if T.indirections != 0 branch only fires because the option's payload is a pointer. The diagnostic says "unwrap the option first", but inside the comptime branch the program already knows the payload is a pointer — the option wrapper should not block the nil comparison.
Compiles. Prints false for id (string is not pointer-typed, falls into return false) and true for parent (option is none).
Current Behavior
error: `?Tag` cannot be used as `nil`, unwrap the option first
8 |return val == unsafe { nil }
|~~~
Possible Solution
Either (a) distinguish ?&T from ?T in T.indirections so the comptime guard maps to the actual pointer-ness of the payload, or (b) teach the ==-with-nil checker to look through the option wrapper when T.indirections != 0. Alternatively, generalize isnil(val) in builtin to accept ?&T so user code has a clean escape hatch.
Describe the bug
The checker rejects a comptime-guarded
val == unsafe { nil }comparison whenvalhas type?&T, even though the$if T.indirections != 0branch only fires because the option's payload is a pointer. The diagnostic says "unwrap the option first", but inside the comptime branch the program already knows the payload is a pointer — the option wrapper should not block thenilcomparison.Reproduction Steps
Expected Behavior
Compiles. Prints
falseforid(string is not pointer-typed, falls intoreturn false) andtrueforparent(option isnone).Current Behavior
Possible Solution
Either (a) distinguish
?&Tfrom?TinT.indirectionsso the comptime guard maps to the actual pointer-ness of the payload, or (b) teach the==-with-nilchecker to look through the option wrapper whenT.indirections != 0. Alternatively, generalizeisnil(val)inbuiltinto accept?&Tso user code has a clean escape hatch.V version
V 0.5.1 (40b3711)
Environment details (OS name and version, etc.)
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.