mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Detach mapping to local in ctx_set_local_type
Similar to the previous fix to ctx_clear_local_types, we must detach mappings to a local if we are changing its value.
This commit is contained in:
parent
6d852e847e
commit
ed8aa3409a
2 changed files with 22 additions and 0 deletions
|
@ -1599,3 +1599,16 @@ assert_equal '10', %q{
|
||||||
|
|
||||||
val
|
val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# regression test of local type change
|
||||||
|
assert_equal '1.1', %q{
|
||||||
|
def bar(baz, quux)
|
||||||
|
if baz.integer?
|
||||||
|
baz, quux = quux, nil
|
||||||
|
end
|
||||||
|
baz.to_s
|
||||||
|
end
|
||||||
|
|
||||||
|
bar(123, 1.1)
|
||||||
|
bar(123, 1.1)
|
||||||
|
}
|
||||||
|
|
|
@ -266,6 +266,15 @@ void ctx_set_local_type(ctx_t* ctx, size_t idx, val_type_t type)
|
||||||
if (idx >= MAX_LOCAL_TYPES)
|
if (idx >= MAX_LOCAL_TYPES)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// If any values on the stack map to this local we must detach them
|
||||||
|
for (int i = 0; i < MAX_TEMP_TYPES; i++) {
|
||||||
|
temp_mapping_t *mapping = &ctx->temp_mapping[i];
|
||||||
|
if (mapping->kind == TEMP_LOCAL && mapping->idx == idx) {
|
||||||
|
ctx->temp_types[i] = ctx->local_types[mapping->idx];
|
||||||
|
*mapping = MAP_STACK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx->local_types[idx] = type;
|
ctx->local_types[idx] = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue