Fix bug in requiring braces for new methods.

This commit is contained in:
David Anderson 2014-06-22 13:28:35 -07:00
parent 354022888f
commit b6eb3b041b
4 changed files with 12 additions and 2 deletions

View File

@ -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) */

View File

@ -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

View File

@ -0,0 +1,8 @@
methodmap Crab {
public Crab() return Crab:5;
};
public main() {
new Crab:crab = Crab();
return _:crab;
}

View File

@ -0,0 +1 @@
expected token: "{", but found "return"