-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
Currently our logic for reflective methods like Object#instance_variable_get, Struct#[], etc goes like this:
- If it's a symbol, look up the value
- If it's a string, turn it into a hard symbol and look up the value
The logic we need to match in MRI is as follows:
- If it's a symbol, look up the value
- If it's a string, see if a symbol exists for that string
- If there is no such symbol, do not create it and do not search (return nil)
MRI only creates symbols for nonexistent key strings passed to the write methods, like instance_variable_set. Our logic has the following issues that should be addressed in some way before 9.2 (or if possible, we should match MRI's logic exactly):
- Hard symbols will leak. This means arbitrary strings passed into reflective read methods could cause a symbol leak.
- Soft symbols pollute the symbol table but would not introduce a symbol leak.
In general MRI will assume that if a string is passed in, and no such symbol exists, no such entry can exists in whatever is being searched.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels