diff options
author | Bad Diode <bd@badd10de.dev> | 2024-06-24 19:30:40 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-06-24 19:30:54 +0200 |
commit | 1c7d30ab77960be3a0c7ae259d601fa6aed640b3 (patch) | |
tree | 9a9aea79bd27d1c70354cee13f528bd499dc6ca2 /tests | |
parent | 8658d71e8a0761f8407b35cdf08b4b80229f560e (diff) | |
download | bdl-1c7d30ab77960be3a0c7ae259d601fa6aed640b3.tar.gz bdl-1c7d30ab77960be3a0c7ae259d601fa6aed640b3.zip |
Add typechecking for structs and struct fields
Diffstat (limited to 'tests')
-rw-r--r-- | tests/semantics.bad | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/semantics.bad b/tests/semantics.bad index 486f6c0..a6810a9 100644 --- a/tests/semantics.bad +++ b/tests/semantics.bad | |||
@@ -8,7 +8,23 @@ enum weekdays { | |||
8 | sun | 8 | sun |
9 | } | 9 | } |
10 | let a = weekdays.tue | 10 | let a = weekdays.tue |
11 | let b = a | 11 | ; let b = a |
12 | |||
13 | struct item { | ||
14 | id: int | ||
15 | name: str | ||
16 | } | ||
17 | |||
18 | ; let a: item = item { | ||
19 | ; id = 1 | ||
20 | ; } | ||
21 | ; let a: item = item ; this shouldn't work, or should it return the default val? | ||
22 | let c: item | ||
23 | set c.id = "hi" | ||
24 | let d = c.id | ||
25 | ; set a.name = "hello" | ||
26 | ; let b = a.id | ||
27 | ; let c = a.name | ||
12 | 28 | ||
13 | ; fun add10(a: int, b: str): int { | 29 | ; fun add10(a: int, b: str): int { |
14 | ; a + 10 | 30 | ; a + 10 |