aboutsummaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-30 22:36:32 +0200
committerEugen Wissner <belka@caraus.de>2026-08-30 22:36:32 +0200
commit26a1b9ad9f347315bc14f2bf3ee064ede51794fc (patch)
tree64ecb7c41cb4b3f26ccbd216197c667d5cd8d8bd /testsuite
parentdbca249757a98d6d56e23db43baa93ad30a91709 (diff)
downloadelna-26a1b9ad9f347315bc14f2bf3ee064ede51794fc.tar.gz
Fix record constructor for base records
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/fail_compilation/record_base_constructor_type_mismatch.elna14
-rw-r--r--testsuite/runnable/record_base_constructor.elna19
2 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/fail_compilation/record_base_constructor_type_mismatch.elna b/testsuite/fail_compilation/record_base_constructor_type_mismatch.elna
new file mode 100644
index 0000000..85c93c1
--- /dev/null
+++ b/testsuite/fail_compilation/record_base_constructor_type_mismatch.elna
@@ -0,0 +1,14 @@
+type
+ Base = record
+ a: Int
+ end
+ Child = record(Base)
+ b: Int
+ end
+
+var
+ c: Child
+
+begin
+ c := Child{a: "wrong", b: 9} (* @Error Expected type 'Int', but got '\[\]const Word8' *)
+end.
diff --git a/testsuite/runnable/record_base_constructor.elna b/testsuite/runnable/record_base_constructor.elna
new file mode 100644
index 0000000..86da08a
--- /dev/null
+++ b/testsuite/runnable/record_base_constructor.elna
@@ -0,0 +1,19 @@
+type
+ Base = record
+ a: Int
+ end
+ Child = record(Base)
+ b: Int
+ end
+ Grandchild = record(Child)
+ c: Int
+ end
+
+var
+ g: Grandchild := Grandchild{a: 3, b: 5, c: 7}
+
+begin
+ assert(g.a = 3);
+ assert(g.b = 5);
+ assert(g.c = 7)
+end.