mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
Assign temporary ID to anonymous ID [Bug #18250]
Dumped iseq binary can not have unnamed symbols/IDs, and ID 0 is stored instead. As `struct rb_id_table` disallows ID 0, also for the distinction, re-assign a new temporary ID based on the local variable table index when loading from the binary, as well as the parser.
This commit is contained in:
parent
eb301d8aec
commit
c14f230b26
Notes:
git
2021-11-23 21:03:49 +09:00
4 changed files with 14 additions and 4 deletions
11
symbol.c
11
symbol.c
|
@ -952,6 +952,17 @@ rb_make_internal_id(void)
|
|||
return next_id_base() | ID_INTERNAL | ID_STATIC_SYM;
|
||||
}
|
||||
|
||||
ID
|
||||
rb_make_temporary_id(size_t n)
|
||||
{
|
||||
const ID max_id = RB_ID_SERIAL_MAX & ~0xffff;
|
||||
const ID id = max_id - (ID)n;
|
||||
if (id <= ruby_global_symbols.last_id) {
|
||||
rb_raise(rb_eRuntimeError, "too big to make temporary ID: %" PRIdSIZE, n);
|
||||
}
|
||||
return (id << ID_SCOPE_SHIFT) | ID_STATIC_SYM | ID_INTERNAL;
|
||||
}
|
||||
|
||||
static int
|
||||
symbols_i(st_data_t key, st_data_t value, st_data_t arg)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue