aboutsummaryrefslogtreecommitdiff
path: root/testsuite/fail_compilation
diff options
context:
space:
mode:
authorEugen Wissner <belka@caraus.de>2026-08-05 01:03:55 +0200
committerEugen Wissner <belka@caraus.de>2026-08-05 21:27:36 +0200
commitb2dee14873402ee3d13d59ae5579593796ea862f (patch)
tree1f245eac1a23a73f45124498fc8274874e35750e /testsuite/fail_compilation
parent1c2fb173ea3b674207badc721556ad72962b266e (diff)
downloadelna-b2dee14873402ee3d13d59ae5579593796ea862f.tar.gz
Check that constants are initialized
Diffstat (limited to 'testsuite/fail_compilation')
-rw-r--r--testsuite/fail_compilation/assign_const_primitive.elna2
-rw-r--r--testsuite/fail_compilation/assign_const_to_pointer.elna2
-rw-r--r--testsuite/fail_compilation/assign_element_of_const.elna2
-rw-r--r--testsuite/fail_compilation/assign_from_const_pointer.elna2
-rw-r--r--testsuite/fail_compilation/const_uninitialized.elna4
5 files changed, 8 insertions, 4 deletions
diff --git a/testsuite/fail_compilation/assign_const_primitive.elna b/testsuite/fail_compilation/assign_const_primitive.elna
index 34b095b..22fef25 100644
--- a/testsuite/fail_compilation/assign_const_primitive.elna
+++ b/testsuite/fail_compilation/assign_const_primitive.elna
@@ -1,6 +1,6 @@
proc f()
var
- x: const Int
+ x: const Int := 4
begin
x := 5 (* @Error Cannot assign to a value of type 'const Int', because it is constant or contains constant members *)
return
diff --git a/testsuite/fail_compilation/assign_const_to_pointer.elna b/testsuite/fail_compilation/assign_const_to_pointer.elna
index c3d9230..87047e5 100644
--- a/testsuite/fail_compilation/assign_const_to_pointer.elna
+++ b/testsuite/fail_compilation/assign_const_to_pointer.elna
@@ -1,5 +1,5 @@
var
- c: const Int
+ c: const Int := 2
p: Pointer
begin
diff --git a/testsuite/fail_compilation/assign_element_of_const.elna b/testsuite/fail_compilation/assign_element_of_const.elna
index 9afd520..a5b5cda 100644
--- a/testsuite/fail_compilation/assign_element_of_const.elna
+++ b/testsuite/fail_compilation/assign_element_of_const.elna
@@ -1,6 +1,6 @@
proc f()
var
- a: const [2]Int
+ a: const [2]Int := [2]Int{ 1, 3 }
begin
a[1] := 6 (* @Error Cannot assign to a value of type 'const Int', because it is constant or contains constant members *)
return
diff --git a/testsuite/fail_compilation/assign_from_const_pointer.elna b/testsuite/fail_compilation/assign_from_const_pointer.elna
index 164bb42..c39d5cd 100644
--- a/testsuite/fail_compilation/assign_from_const_pointer.elna
+++ b/testsuite/fail_compilation/assign_from_const_pointer.elna
@@ -1,5 +1,5 @@
var
- cv: const Pointer
+ cv: const Pointer := nil
p: Pointer
begin
diff --git a/testsuite/fail_compilation/const_uninitialized.elna b/testsuite/fail_compilation/const_uninitialized.elna
new file mode 100644
index 0000000..06db3d7
--- /dev/null
+++ b/testsuite/fail_compilation/const_uninitialized.elna
@@ -0,0 +1,4 @@
+var
+ x: const Int (* @Error All constants should be initialized *)
+
+end.