sm
This commit is contained in:
@@ -1,26 +0,0 @@
|
||||
// Issue 0008: Chained ?? (null coalescing) doesn't work
|
||||
//
|
||||
// `a ?? b ?? c` where a: ?f32, b: ?f32, c: f32 fails with:
|
||||
// "narrowing conversion from '?f32' to 'f32' requires explicit 'xx' cast"
|
||||
//
|
||||
// It parses as (a ?? b) ?? c, and the first ?? rejects ?f32 as the rhs.
|
||||
//
|
||||
// Expected: ?? should either be right-associative so it parses as a ?? (b ?? c),
|
||||
// or allow ?T as the rhs (returning ?T when rhs is optional, T when rhs is concrete).
|
||||
//
|
||||
// Workaround: use parentheses — a ?? (b ?? c)
|
||||
|
||||
Foo :: struct {
|
||||
x: ?f32;
|
||||
y: ?f32;
|
||||
}
|
||||
|
||||
main :: () -> void {
|
||||
f := Foo.{ x = 1.0, y = 2.0 };
|
||||
|
||||
// This works:
|
||||
ok := f.x ?? (f.y ?? 0.0);
|
||||
|
||||
// This should also work but fails:
|
||||
bad := f.x ?? f.y ?? 0.0;
|
||||
}
|
||||
Reference in New Issue
Block a user