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.
This commit is contained in:
Michael Schimmel
2026-02-24 11:37:31 +01:00
parent 683d0f4dbe
commit 2c652e0140
4 changed files with 152 additions and 6 deletions
+20
View File
@@ -0,0 +1,20 @@
(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
)