From f82ceebe9459c230c7e755eff8ca92e5c733e862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Grubbstr=C3=B6m=20=28Grubba=29?= <grubba@grubba.org> Date: Tue, 14 Nov 2017 18:55:19 +0100 Subject: [PATCH] Compiler: Improved variant robustness. Perform a more lenient scan for the previous definition of a variant in the second pass. Should fix issues with not finding variants in the second pass, causing the fatal "Internal error: Not allowed to add more identifiers during second compiler pass." --- src/program.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/program.c b/src/program.c index 237df63a9d..28ac4e6be1 100644 --- a/src/program.c +++ b/src/program.c @@ -6696,6 +6696,7 @@ int really_low_find_variant_identifier(struct pike_string *name, struct reference *funp; struct identifier *fun; int id, i, depth, last_inh; + int tentative = -1; #if 1 #ifdef COMPILER_DEBUG @@ -6737,7 +6738,14 @@ int really_low_find_variant_identifier(struct pike_string *name, fun = ID_FROM_PTR(prog, funp); /* if(fun->func.offset == -1) continue; * Prototype */ if(!is_same_string(fun->name,name)) continue; - if(type && (fun->type != type)) continue; + if(type && (fun->type != type)) { + if ((Pike_compiler->compiler_pass == 2) && + !(funp->id_flags & ID_INHERITED) && + match_types(fun->type, type)) { + tentative = i; + } + continue; + } if(funp->id_flags & ID_INHERITED) { struct inherit *inh = INHERIT_FROM_PTR(prog, funp); @@ -6770,6 +6778,7 @@ int really_low_find_variant_identifier(struct pike_string *name, return i; } } + if (id < 0) id = tentative; CDFPRINTF((stderr, "Found %d\n", id)); return id; } -- GitLab