From eed58fa9d2bccf9df9128e6eff08fcd08b6fa95e Mon Sep 17 00:00:00 2001 From: Bad Diode Date: Wed, 19 Jun 2024 08:43:17 +0200 Subject: Change a few syntax constructs for consistency --- tests/conditionals.bad | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tests/conditionals.bad') diff --git a/tests/conditionals.bad b/tests/conditionals.bad index 856ac8a..e1a456e 100644 --- a/tests/conditionals.bad +++ b/tests/conditionals.bad @@ -1,26 +1,26 @@ ; Basic if expressions. -if true "hello" +if (true) "hello" ; These can produce values and the result bound to a name. let a = if (2 + 2 >= 4) 42 ; We support a single if expression. -let b = if 0xff == 255 "hello" else "world" +let b = if (0xff == 255) "hello" else "world" ; ... but these can compound on each other -if 1 < 2 6 -else if 1 > 2 7 +if (1 < 2) 6 +else if (1 > 2) 7 else 8 ; A block is an expression, and if raise the scope level regardless if a block ; is used or not. -if true != false { +if (true != false) { let a = "yo" } ; Match cases should only apply to literal values, for example `case 1 + 2` ; isn't allowed. They should generally convert to a lookup table. -match a = { +match (a) { case 8 = "hello" case 9 = "world" else = "what" @@ -37,7 +37,7 @@ enum flags { let a:flags = flags.node_add ; No need to qualify enum fields inside match-case. -match a = { +match (a) { case node_add = "adding something..." case node_add = "subbing something..." else = "default case" -- cgit v1.2.1