Merge pull request #172 from alliedmodders/fix-setters
Fix a crash when properties have setters but not getters.
This commit is contained in:
commit
a7303568d6
@ -3686,8 +3686,7 @@ int parse_property_accessor(const typeinfo_t *type, methodmap_t *map, methodmap_
|
||||
|
||||
// Must have one extra argument taking the return type.
|
||||
arginfo *arg = &target->dim.arglist[1];
|
||||
if (arg->ident == 0 ||
|
||||
arg->ident != iVARIABLE ||
|
||||
if (arg->ident != iVARIABLE ||
|
||||
arg->hasdefault ||
|
||||
arg->numtags != 1 ||
|
||||
arg->tags[0] != type->tag)
|
||||
|
@ -2174,7 +2174,7 @@ restart:
|
||||
rvalue(lval1);
|
||||
clear_value(lval1);
|
||||
lval1->ident = iACCESSOR;
|
||||
lval1->tag = method->getter->tag;
|
||||
lval1->tag = method->property_tag();
|
||||
lval1->accessor = method;
|
||||
lvalue = TRUE;
|
||||
goto restart;
|
||||
|
@ -85,6 +85,19 @@ typedef struct methodmap_method_s
|
||||
symbol *target;
|
||||
symbol *getter;
|
||||
symbol *setter;
|
||||
|
||||
int property_tag() const {
|
||||
assert(getter || setter);
|
||||
if (getter)
|
||||
return getter->tag;
|
||||
arginfo *thisp = &setter->dim.arglist[0];
|
||||
if (thisp->ident == 0)
|
||||
return pc_tag_void;
|
||||
arginfo *valp = &setter->dim.arglist[1];
|
||||
if (valp->ident != iVARIABLE || valp->numtags != 1)
|
||||
return pc_tag_void;
|
||||
return valp->tags[0];
|
||||
}
|
||||
} methodmap_method_t;
|
||||
|
||||
typedef struct methodmap_s
|
||||
|
12
sourcepawn/compiler/tests/ok-setter-no-getter.sp
Normal file
12
sourcepawn/compiler/tests/ok-setter-no-getter.sp
Normal file
@ -0,0 +1,12 @@
|
||||
methodmap Crab
|
||||
{
|
||||
property int X {
|
||||
public native set(int value);
|
||||
}
|
||||
}
|
||||
|
||||
public main()
|
||||
{
|
||||
Crab crab;
|
||||
crab.X = 12;
|
||||
}
|
Loading…
Reference in New Issue
Block a user