no :: in func decls
This commit is contained in:
@@ -30,7 +30,7 @@ Box :: union(enum) {
|
||||
|
||||
# Statement match with payload capture; every variant returns, so the function needs
|
||||
# no trailing return (the desugared if/else chain covers all paths).
|
||||
describe :: func(d Data) i32 {
|
||||
describe func(d Data) i32 {
|
||||
match d {
|
||||
.dog |age|: return age + 1
|
||||
.bird |wingspan|: return wingspan + 2
|
||||
@@ -38,7 +38,7 @@ describe :: func(d Data) i32 {
|
||||
}
|
||||
|
||||
# Value match: single-expression arms yield implicitly, a block arm yields explicitly.
|
||||
area :: func(s Shape) i32 {
|
||||
area func(s Shape) i32 {
|
||||
result :: match s {
|
||||
.square |side|: side * side
|
||||
.circle |r|: {
|
||||
@@ -51,18 +51,18 @@ area :: func(s Shape) i32 {
|
||||
|
||||
# Same-type multi-pattern capture: `.dog` and `.bird` are both i32, so one capture binds
|
||||
# either payload (read once at the union's shared carrier offset).
|
||||
payload_of :: func(d Data) i32 {
|
||||
payload_of func(d Data) i32 {
|
||||
v :: match d {
|
||||
.dog, .bird |n|: n
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
make_box :: func() Box {
|
||||
make_box func() Box {
|
||||
return Box{ point = Point{ x = 4, y = 0 } }
|
||||
}
|
||||
|
||||
main :: func() i32 {
|
||||
main func() i32 {
|
||||
acc i32 = 0
|
||||
|
||||
dog Data = Data{ dog = 9 }
|
||||
|
||||
Reference in New Issue
Block a user