From e9dd8c53e59b2b8346e65581f9374428a61b24a2 Mon Sep 17 00:00:00 2001 From: Joel Martin Date: Tue, 20 Aug 2024 11:38:11 -0500 Subject: [PATCH] sml: fix mlton self-host. Full syntax err in catch* In mlton mode, syntax errors caught in the try/catch block were being processed as "SyntaxError" without any additional context/message. Explicitly pass the full message always. --- impls/sml/step9_try.sml | 1 + impls/sml/stepA_mal.sml | 1 + impls/tests/step9_try.mal | 1 + 3 files changed, 3 insertions(+) diff --git a/impls/sml/step9_try.sml b/impls/sml/step9_try.sml index ee3a8783..afbe45ee 100644 --- a/impls/sml/step9_try.sml +++ b/impls/sml/step9_try.sml @@ -71,6 +71,7 @@ and evalTry e [a, LIST ([SYMBOL "catch*", b, c],_)] = (eval e a handle ex => eva and evalCatch e b ex body = eval (bind [b, exnVal ex] e) body and exnVal (MalException x) = x + | exnVal (SyntaxError msg) = STRING msg | exnVal (NotDefined msg) = STRING msg | exnVal (NotApplicable msg) = STRING msg | exnVal (OutOfBounds msg) = STRING msg diff --git a/impls/sml/stepA_mal.sml b/impls/sml/stepA_mal.sml index 4c1119dd..497e7714 100644 --- a/impls/sml/stepA_mal.sml +++ b/impls/sml/stepA_mal.sml @@ -71,6 +71,7 @@ and evalTry e [a, LIST ([SYMBOL "catch*", b, c],_)] = (eval e a handle ex => eva and evalCatch e b ex body = eval (bind [b, exnVal ex] e) body and exnVal (MalException x) = x + | exnVal (SyntaxError msg) = STRING msg | exnVal (NotDefined msg) = STRING msg | exnVal (NotApplicable msg) = STRING msg | exnVal (OutOfBounds msg) = STRING msg diff --git a/impls/tests/step9_try.mal b/impls/tests/step9_try.mal index 975cb541..b3a5b1ed 100644 --- a/impls/tests/step9_try.mal +++ b/impls/tests/step9_try.mal @@ -41,6 +41,7 @@ (try* (map throw (list "my err")) (catch* exc exc)) ;=>"my err" + ;; ;; Testing builtin functions