Commit a6453352
a64533525e58Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 3 files · +2 added · ~1 modified
Description
Merge pull request #1010 from OriPekelman/fix/regex-namespaced-const
codegen: resolve a regex held in a namespaced constant (M::RE)
Details
- Commit
- a64533525e58
- Parent
- eadc38a27532
- Merge parent
- 66b013c463c5
spinel_codegen.rbmodifiedView file
@@ -1998,7 +1998,11 @@
19981998
# Also unwrap `.freeze` (`PATTERN = /pat/.freeze`) — Prism wraps19991999
# the literal in a `freeze` CallNode whose receiver is the20002000
# RegularExpressionNode. .2001-
if @nd_type[nid] == "ConstantReadNode"2001+
# ConstantPathNode (`M::RX`) resolves the same way — resolve_const_ref_name2002+
# already maps `M::RX` to the registered name `M_RX`. Without this, a2003+
# namespaced constant regex fell through, so `s.gsub(M::RX, ...)` silently2004+
# no-op'd and `s.scan(M::RX)` raised undefined-method (e.g. emoji_regex).2005+
if @nd_type[nid] == "ConstantReadNode" || @nd_type[nid] == "ConstantPathNode"20022006
cname = resolve_const_ref_name(nid)20032007
if cname != ""20042008
ci = find_const_idx(cname)test/regex_namespaced_const.rbaddedView file
Loading diff…
test/regex_namespaced_const.rb.expectedaddedView file
Loading diff…