Files
RustAst/examples/pattern-rules.myc
T
Michael Schimmel 2c652e0140 feat: Improve destructuring and function call type checking
Refine the type checker to correctly handle destructuring of various
collection types (tuples, vectors, matrices, lists, records).

Additionally, prevent implicit type coercion for function arguments,
ensuring that only tuples are passed to functions expecting tuple
arguments. This avoids unexpected behavior where vectors or matrices
might be treated as tuples.

Add a new example file demonstrating pattern matching and destructuring
rules.
2026-02-24 11:37:31 +01:00

21 lines
480 B
Plaintext

(do
(def val1 4) ; korrekt
(def val2 [4 5]) ; korrekt
(def [val3] 5) ; falsch
(def [val4] [5]) ; korrekt
(def [[x1 [y1 y3]] z1] [[1 [2 3]] 4]) ; korrekt
(def [[x2 [y2 y4]] z2] [1 2 3 4]) ; falsch
;(def [[x [y1 y2]] z] [1] [2 3] 4) ; falsch
;(def [[x [y1 y2]] z] [1 [2 3]] 4) ; falsch
(def f (fn [[x [y1 y2]] z] (+ x y1 y2 z)))
(f [1 [2 3]] 4) ; korrekt
(f [1 2 3 4]) ; falsch
(f [1 2 [3] 4]) ; falsch
(f 1 2 3 4) ; falsch
(f 1 [2 [3]] 4) ; falsch
(f [[1 2] [3 4]]) ; falsch
)