fixed wrong spec decoding in core.basicAt and core.basicAtPut functions

This commit is contained in:
2025-09-03 23:08:20 +09:00
parent e64b7c495b
commit ad510b1436
3 changed files with 66 additions and 63 deletions

View File

@ -548,7 +548,7 @@ static HAK_INLINE int decode_spec (hak_t* hak, hak_oop_class_t _class, hak_oow_t
if (num_flexi_fields > HAK_MAX_INDEXED_INSTVARS(num_fixed_fields))
{
hak_seterrbfmt (hak, HAK_EINVAL, "number of flexi-fields(%zu) too big for a class %O", num_flexi_fields, _class);
hak_seterrbfmt(hak, HAK_EINVAL, "number of flexi-fields(%zu) too big for class %O", num_flexi_fields, _class);
return -1;
}
}
@ -566,7 +566,7 @@ static HAK_INLINE int decode_spec (hak_t* hak, hak_oop_class_t _class, hak_oow_t
if (num_flexi_fields > 0)
{
hak_seterrbfmt (hak, HAK_EPERM, "flexi-fields(%zu) disallowed for a class %O", num_flexi_fields, _class);
hak_seterrbfmt(hak, HAK_EPERM, "flexi-fields(%zu) disallowed for class %O", num_flexi_fields, _class);
return -1;
}
}

View File

@ -102,7 +102,7 @@ static hak_pfrc_t __basic_at (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, int s
{
hak_oow_t fixed, flexi;
fixed = HAK_CLASS_SPEC_NAMED_INSTVARS(_class->spec);
fixed = HAK_CLASS_SPEC_NAMED_INSTVARS(HAK_OOP_TO_SMOOI(_class->spec));
flexi = HAK_OBJ_GET_SIZE(obj) - fixed;
if (index >= flexi)
{
@ -210,7 +210,7 @@ static hak_pfrc_t __basic_at_put (hak_t* hak, hak_mod_t* mod, hak_ooi_t nargs, i
{
hak_oow_t fixed, flexi;
fixed = HAK_CLASS_SPEC_NAMED_INSTVARS(_class->spec);
fixed = HAK_CLASS_SPEC_NAMED_INSTVARS(HAK_OOP_TO_SMOOI(_class->spec));
flexi = HAK_OBJ_GET_SIZE(obj) - fixed;
if (index >= flexi)
{

View File

@ -136,15 +136,18 @@ printf "----------------------------------------\n"
k := #[1 2 3]
printf "%O\n" (k:basicAt 2)
class Z: Object [ a b c ] {
class (#varying) Z: Object [ a b c ] {
fun(#classinst) new() {
self.a := 10
self.b := 20
self.c := 30
printf "Z:new called\n"
}
}
##k := (Z:basicNew 0)
k := (Z:new)
k := (Z:basicNew 10)
##k := (Z:new)
k:basicAtPut 2 "hello"
k:basicAtPut 3 "world"
printf "----------------------------------------\n"
printf "%O\n" (k:basicAt 2)