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
`varDecl` (with optional type) is used in `let` statements where type inference is allowed. `typedVarDecl` (type required) is used for struct fields and function parameters where types are mandatory.
121
+
117
122
Since `typeSpec` includes reference types (`&[T]`), a `typed_scalar_decl` like `arr: &[i32]` declares a slice reference parameter. This form is only valid in function parameter lists — it cannot appear in `let` statements or struct fields. This constraint is enforced semantically, not syntactically.
118
123
119
124
Examples:
@@ -155,11 +160,12 @@ let count = 0; // type inference scalar
155
160
156
161
## Structure Definitions
157
162
158
-
Define custom types using the `struct` keyword with named fields. Struct fields use `varDecl` (scalars and arrays only; reference types are not permitted as struct fields).
163
+
Define custom types using the `struct` keyword with named fields. Struct fields must have type annotations (reference types are not permitted as struct fields).
Declare function signatures with optional return types. Function parameters use `varDecl`, which includes reference-typed parameters like `arr: &[i32]` via `typeSpec`.
185
+
Declare function signatures with optional return types. Function parameters must have type annotations, including reference-typed parameters like `arr: &[i32]` via `typeSpec`.
0 commit comments