fix for deprecated when's where the inner frame is larger than the outer frame

This commit is contained in:
Vern Paxson 2022-09-25 19:55:47 -07:00
parent 19ba30d77a
commit 71d1022269
3 changed files with 20 additions and 1 deletions

View file

@ -190,6 +190,20 @@ ScopePtr pop_scope()
return old_top;
}
void merge_top_scope()
{
if ( scopes.size() < 2 )
reporter->InternalError("scope merge underflow");
auto t = pop_scope();
for ( auto v : t->OrderedVars() )
{
v->SetOffset(top_scope->Length());
top_scope->Insert(v->Name(), v);
}
}
ScopePtr current_scope()
{
return top_scope;

View file

@ -92,6 +92,11 @@ extern void push_existing_scope(ScopePtr scope);
// Returns the one popped off.
extern ScopePtr pop_scope();
// Merges the elements of the current scope with the one surrounding it,
// popping it in the process.
extern void merge_top_scope();
extern ScopePtr current_scope();
extern ScopePtr global_scope();

View file

@ -1893,7 +1893,7 @@ void WhenInfo::Build(StmtPtr ws)
{
if ( IsDeprecatedSemantics(ws) )
{
pop_scope();
merge_top_scope();
return;
}