Branch: Tag:

2021-03-28

2021-03-28 14:34:09 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [Typechecker]: Fixup the type for classes before end_first_pass().

3410:    }    }    -  if(Pike_compiler->compiler_pass != COMPILER_PASS_LAST) -  p=end_first_pass(0); -  else -  p=end_first_pass(1); -  -  /* fprintf(stderr, "LANGUAGE.YACC: CLASS end\n"); */ -  -  if(p) { +     /* Update the type for the program constant, -  * since we might have a lfun::create(). */ +  * since we may have a lfun::create(). +  * +  * Do this before end_first_pass(), to keep +  * override_identifier() et al happy. +  */ +  {    struct identifier *i;    struct svalue sv; -  SET_SVAL(sv, T_PROGRAM, 0, program, p); -  i = ID_FROM_INT(Pike_compiler->new_program, $<number>4); +  SET_SVAL(sv, T_PROGRAM, 0, program, Pike_compiler->new_program); +  i = ID_FROM_INT(Pike_compiler->previous->new_program, $<number>4);    free_type(i->type);    i->type = get_type_of_svalue(&sv); -  if (p->flags & PROGRAM_CONSTANT) { +  if (Pike_compiler->new_program->flags & PROGRAM_CONSTANT) {    /* Update, in case of @constant. */    i->opt_flags = 0;    } -  +  } +  +  if(Pike_compiler->compiler_pass != COMPILER_PASS_LAST) +  p=end_first_pass(0); +  else +  p=end_first_pass(1); +  +  /* fprintf(stderr, "LANGUAGE.YACC: CLASS end\n"); */ +  +  if(p) {    free_program(p);    } else if (!Pike_compiler->num_parse_error) {    /* Make sure code in this class is aware that something went wrong. */