diff --git a/lib/comp.c b/lib/comp.c index 68305ad..3df15ed 100644 --- a/lib/comp.c +++ b/lib/comp.c @@ -3533,6 +3533,13 @@ static HCL_INLINE int compile_catch (hcl_t* hcl) HCL_ASSERT (hcl, fbi->tmpr_nargs + fbi->tmpr_nrvars + fbi->tmpr_nlvars == fbi->tmprcnt - par_tmprcnt); obj = HCL_CNODE_CONS_CDR(obj); + if (!obj) + { + /* the error message is no exception handler. but what is expected is an expression. + * e.g. a number, nil, a block expression, etc */ + hcl_setsynerrbfmt (hcl, HCL_SYNERR_NOVALUE, HCL_CNODE_GET_LOC(exarg), HCL_NULL, "no exception handler after %.*js", HCL_CNODE_GET_TOKLEN(cmd), HCL_CNODE_GET_TOKPTR(cmd)); + return -1; + } /* jump_inst_pos hold the instruction pointer that skips the catch block at the end of the try block */ patch_nearest_post_try (hcl, &jump_inst_pos); diff --git a/lib/prim.c b/lib/prim.c index e5d8a1d..d9eb6d8 100644 --- a/lib/prim.c +++ b/lib/prim.c @@ -300,7 +300,7 @@ static hcl_pfrc_t pf_nqk (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs) /* ------------------------------------------------------------------------- */ -static hcl_pfrc_t pf_is_null (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs) +static hcl_pfrc_t pf_is_nil (hcl_t* hcl, hcl_mod_t* mod, hcl_ooi_t nargs) { hcl_oop_t rv; rv = (HCL_STACK_GETARG(hcl, nargs, 0) == hcl->_nil)? hcl->_true: hcl->_false; @@ -924,7 +924,7 @@ static pf_t builtin_prims[] = { 2, 2, pf_nql, 4, { 'n','q','l','?' } }, { 2, 2, pf_nqk, 4, { 'n','q','k','?' } }, - { 1, 1, pf_is_null, 5, { 'n','u','l','l','?' } }, + { 1, 1, pf_is_nil, 4, { 'n','i','l','?' } }, { 1, 1, pf_is_boolean, 8, { 'b','o','o','l','e','a','n','?' } }, { 1, 1, pf_is_character, 10, { 'c','h','a','r','a','c','t','e','r','?' } }, { 1, 1, pf_is_error, 6, { 'e','r','r','o','r','?' } }, diff --git a/lib/print.c b/lib/print.c index 0466dea..50925ce 100644 --- a/lib/print.c +++ b/lib/print.c @@ -102,7 +102,7 @@ static struct } word[] = { { 8, { '#','<','U','N','D','E','F','>' } }, - { 4, { 'n','u','l','l' } }, + { 3, { 'n','i','l' } }, { 4, { 't','r','u','e' } }, { 5, { 'f','a','l','s','e' } }, diff --git a/t/call-5001.err b/t/call-5001.err index ab11e79..e018463 100644 --- a/t/call-5001.err +++ b/t/call-5001.err @@ -9,3 +9,7 @@ try { } catch (e a) { ##ERROR: syntax error - not proper exception variable printf "EXCEPTION - %s\n" e } + +--- + +try { throw "1111"; } catch (e) ##ERROR: syntax error - no exception handler