Fix bug in requiring braces for new methods.
This commit is contained in:
parent
354022888f
commit
b6eb3b041b
sourcepawn/compiler
@ -235,7 +235,6 @@ typedef struct s_symbol {
|
||||
#define sGLOBAL 0 /* global variable/constant class (no states) */
|
||||
#define sLOCAL 1 /* local variable/constant */
|
||||
#define sSTATIC 2 /* global life, local scope */
|
||||
#define sPROXY 3 /* only find proxies */
|
||||
|
||||
#define sSTATEVAR 3 /* criterion to find variables (sSTATEVAR implies a global variable) */
|
||||
|
||||
|
@ -82,6 +82,7 @@ typedef struct funcstub_setup_s {
|
||||
const char *name;
|
||||
int return_tag;
|
||||
int this_tag;
|
||||
int is_new;
|
||||
} funcstub_setup_t;
|
||||
|
||||
static void resetglobals(void);
|
||||
@ -3559,6 +3560,7 @@ methodmap_method_t *parse_method(methodmap_t *map)
|
||||
check_name_length(fullname);
|
||||
|
||||
setup.name = fullname;
|
||||
setup.is_new = TRUE;
|
||||
|
||||
if (is_native) {
|
||||
target = funcstub(TRUE, &setup);
|
||||
@ -4927,7 +4929,7 @@ static int newfunc(const funcstub_setup_t *setup,int fpublic,int fstatic,int sto
|
||||
lexpush();
|
||||
} else {
|
||||
// We require '{' for new methods.
|
||||
if (setup->this_tag != -1)
|
||||
if (setup->is_new)
|
||||
needtoken('{');
|
||||
|
||||
/* Insert a separator so that comments following the statement will not
|
||||
|
8
sourcepawn/compiler/tests/fail-method-requires-brace.sp
Normal file
8
sourcepawn/compiler/tests/fail-method-requires-brace.sp
Normal file
@ -0,0 +1,8 @@
|
||||
methodmap Crab {
|
||||
public Crab() return Crab:5;
|
||||
};
|
||||
|
||||
public main() {
|
||||
new Crab:crab = Crab();
|
||||
return _:crab;
|
||||
}
|
1
sourcepawn/compiler/tests/fail-method-requires-brace.txt
Normal file
1
sourcepawn/compiler/tests/fail-method-requires-brace.txt
Normal file
@ -0,0 +1 @@
|
||||
expected token: "{", but found "return"
|
Loading…
Reference in New Issue
Block a user