21 lines
500 B
Plaintext
21 lines
500 B
Plaintext
// Issue 0009: Struct-level constant declarations
|
|
//
|
|
// Constants declared inside a struct body with `NAME :Type: value;` syntax
|
|
// fail with "expected field name in struct".
|
|
//
|
|
// Expected: structs should support constant declarations alongside fields and methods.
|
|
|
|
Foo :: struct {
|
|
x: f32;
|
|
|
|
// This method works:
|
|
get_x :: (self: *Foo) -> f32 { self.x; }
|
|
|
|
// This constant should work but fails:
|
|
DEFAULT_X :f32: 42.0;
|
|
}
|
|
|
|
main :: () -> void {
|
|
f := Foo.{ x = Foo.DEFAULT_X };
|
|
}
|