fixed the compiler to check the presense of the exception handler expression in the catch part
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
7634df5449
commit
2437fadedf
@ -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);
|
HCL_ASSERT (hcl, fbi->tmpr_nargs + fbi->tmpr_nrvars + fbi->tmpr_nlvars == fbi->tmprcnt - par_tmprcnt);
|
||||||
|
|
||||||
obj = HCL_CNODE_CONS_CDR(obj);
|
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 */
|
/* 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);
|
patch_nearest_post_try (hcl, &jump_inst_pos);
|
||||||
|
@ -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;
|
hcl_oop_t rv;
|
||||||
rv = (HCL_STACK_GETARG(hcl, nargs, 0) == hcl->_nil)? hcl->_true: hcl->_false;
|
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_nql, 4, { 'n','q','l','?' } },
|
||||||
{ 2, 2, pf_nqk, 4, { 'n','q','k','?' } },
|
{ 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_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_character, 10, { 'c','h','a','r','a','c','t','e','r','?' } },
|
||||||
{ 1, 1, pf_is_error, 6, { 'e','r','r','o','r','?' } },
|
{ 1, 1, pf_is_error, 6, { 'e','r','r','o','r','?' } },
|
||||||
|
@ -102,7 +102,7 @@ static struct
|
|||||||
} word[] =
|
} word[] =
|
||||||
{
|
{
|
||||||
{ 8, { '#','<','U','N','D','E','F','>' } },
|
{ 8, { '#','<','U','N','D','E','F','>' } },
|
||||||
{ 4, { 'n','u','l','l' } },
|
{ 3, { 'n','i','l' } },
|
||||||
{ 4, { 't','r','u','e' } },
|
{ 4, { 't','r','u','e' } },
|
||||||
{ 5, { 'f','a','l','s','e' } },
|
{ 5, { 'f','a','l','s','e' } },
|
||||||
|
|
||||||
|
@ -9,3 +9,7 @@ try {
|
|||||||
} catch (e a) { ##ERROR: syntax error - not proper exception variable
|
} catch (e a) { ##ERROR: syntax error - not proper exception variable
|
||||||
printf "EXCEPTION - %s\n" e
|
printf "EXCEPTION - %s\n" e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
try { throw "1111"; } catch (e) ##ERROR: syntax error - no exception handler
|
||||||
|
Loading…
Reference in New Issue
Block a user