Files
sx/examples/issue-0009.sx
agra dd14f1206b ir
2026-02-26 02:25:02 +02:00

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 };
}