From de360fb4023c4a18961817bcdb248e0720de7ec7 Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 26 Jun 2024 17:45:55 +0200 Subject: Fix a segfault --- src/main.c | 6 +++--- tests/conditionals.bad | 13 ++++--------- tests/loops.bad | 7 +------ tests/variables.bad | 20 +++++++++----------- 4 files changed, 17 insertions(+), 29 deletions(-) diff --git a/src/main.c b/src/main.c index 8026d0d..40d9ad0 100644 --- a/src/main.c +++ b/src/main.c @@ -191,7 +191,7 @@ graph_typescope(Scope *scope, Arena a) { " %s " " %s" "", - type->key, type->val); + type->key, type->val.name); type = symmap_next(&iter, &a); } println(">];"); @@ -900,8 +900,8 @@ type_inference(Analyzer *a, Node *node, Scope *scope) { eprintln( "%s:%d:%d: error: struct incomplete struct literal " "'%s', did you mean to use %s:{}?", - a->file_name, node->line, node->col, type->val, - type->val); + a->file_name, node->line, node->col, symbol, + symbol); a->err = true; return cstr(""); } else { diff --git a/tests/conditionals.bad b/tests/conditionals.bad index 772bd07..aca5c36 100644 --- a/tests/conditionals.bad +++ b/tests/conditionals.bad @@ -36,15 +36,10 @@ enum flags { } let f:flags = flags.node_add -; TODO: No need to qualify enum fields inside match-case. -; match (a) { -; case node_add = "adding something..." -; case node_add = "subbing something..." -; else = "default case" -; } -match a { - case flags.node_add = "adding something..." - case flags.node_add = "subbing something..." +; No need to qualify enum fields inside match-case. +match f { + case node_add = "adding something..." + case node_add = "subbing something..." else = "default case" } diff --git a/tests/loops.bad b/tests/loops.bad index a068ed0..be2628e 100644 --- a/tests/loops.bad +++ b/tests/loops.bad @@ -16,10 +16,5 @@ while i < 10 { "hello" ; --i } -; TODO: add post/pre increment tokens -; TODO: add functions -; TODO: add function calls - -; for let i = 1, 1 < 10, i++ { -; } +; TODO: add post/pre increment tokens diff --git a/tests/variables.bad b/tests/variables.bad index 34293dc..ce765bc 100644 --- a/tests/variables.bad +++ b/tests/variables.bad @@ -33,27 +33,25 @@ let player_b = player_a struct entity { pos: vec vel: vec - ; TODO: ... - ; attr: { - ; id: u64 - ; name: str - ; } + attr: { + id: int + name: str + } } ; Symbols followed by curly braces output struct literals. let particle = entity : { ; Two ways of initializing inner fields. pos = vec : { x = 1.0 y = 2.0 } - ; TODO: Get rid of this, unnecessary complexity on the implementation, let's - ; just do the top option. - ; attr.id = 1 - ; attr.name = "particle" + attr = { + id = 1 + name = "particle" + } ; Missing initialization fields default to zero. vel = vec : { y = -3.0 } } -; let particle = entity : {} -; TODO: Now we can get rid of parenthesis on if/while statements +set particle = entity : {} ; ; We can have static arrays and have indexed access. ; let numbers: u32[0xff] -- cgit v1.2.1