From 9e936277c7850c871f803d3bb813f417e8099ee5 Mon Sep 17 00:00:00 2001 From: TudbuT Date: Sat, 16 Nov 2024 00:21:05 +0100 Subject: [PATCH] reject nulls in match inputs entirely --- spl/std.spl | 10 ++++++++-- src/lexer.rs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/spl/std.spl b/spl/std.spl index 3b516a5..152633f 100644 --- a/spl/std.spl +++ b/spl/std.spl @@ -648,7 +648,10 @@ func times { | with amount callable ; } func check-match { bool | with input output ; - output gettype "func" eq input null eq not and if { + input null eq if { + 0 2 stop + } + output gettype "func" eq if { 1 2 stop } input output eq if { @@ -686,7 +689,10 @@ func match-unchecked { | with input output ; } func match { bool | with input output ; - output gettype "func" eq input null eq not and if { + input null eq if { + 0 2 stop + } + output gettype "func" eq if { input output call 1 2 stop } diff --git a/src/lexer.rs b/src/lexer.rs index dbb494a..9ac1f49 100644 --- a/src/lexer.rs +++ b/src/lexer.rs @@ -138,7 +138,7 @@ fn read_block_dyn( run_as_base: false, })))) } - x if x.len() >= 2 && &x[0..2] == "!{" => { + x if x.len() >= 2 && x.get(0..2) == Some("!{") => { words.push(Word::Const(Value::Str(x[2..].to_owned()))); } "<" => {