added more test-cases for class redefintion
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
hyung-hwan 2024-07-22 18:28:21 +09:00
parent 28c05ff903
commit 0e2dfea7fb
2 changed files with 40 additions and 0 deletions

View File

@ -3559,10 +3559,12 @@ static int execute (hcl_t* hcl)
/* store or pop */ /* store or pop */
if (HCL_IS_CLASS(hcl, ass->cdr) && ((hcl_oop_class_t)ass->cdr)->name == ass->car) if (HCL_IS_CLASS(hcl, ass->cdr) && ((hcl_oop_class_t)ass->cdr)->name == ass->car)
{ {
/* the existing value must be a class. disallow re-definition */
hcl_seterrbfmt (hcl, HCL_EPERM, "prohibited redefintion of %.*js", HCL_OBJ_GET_SIZE(ass->car), HCL_OBJ_GET_CHAR_SLOT(ass->car)); hcl_seterrbfmt (hcl, HCL_EPERM, "prohibited redefintion of %.*js", HCL_OBJ_GET_SIZE(ass->car), HCL_OBJ_GET_CHAR_SLOT(ass->car));
if (do_throw_with_internal_errmsg(hcl, fetched_instruction_pointer) >= 0) break; if (do_throw_with_internal_errmsg(hcl, fetched_instruction_pointer) >= 0) break;
goto oops_with_errmsg_supplement; goto oops_with_errmsg_supplement;
} }
ass->cdr = HCL_STACK_GETTOP(hcl); ass->cdr = HCL_STACK_GETTOP(hcl);
if ((bcode >> 2) & 1) if ((bcode >> 2) & 1)

View File

@ -147,3 +147,41 @@ class X [ a b c ] {
} }
} }
} }
---
class F {
}
class F { ##ERROR: exception not handled - "prohibited redefintion of F
}
---
class F {
}
F := 30 ##ERROR: exception not handled - "prohibited redefintion of F
---
class F {
}
F := (class { ##ERROR: exception not handled - "prohibited redefintion of F"
})
---
F := (class {
})
F := (class F { ##ERROR: exception not handle - "prohibited redefintion of F"
})
## TDOO: do we need to allow the above?
##F := 30
##class F { ##ERROR: exception not handled - "prohibited redefintion of F"
##}