Fix how Prism parses encoding from shebang args (#!)#11445
Fix how Prism parses encoding from shebang args (#!)#11445kddnewton merged 1 commit intoruby:masterfrom
#!)#11445Conversation
| pm_options_command_line_set(options, prism_script_command_line(opt)); | ||
| if (opt->ext.enc.name != 0) { | ||
| pm_options_encoding_set(options, StringValueCStr(opt->ext.enc.name)); | ||
| opt->ext.enc.index = opt_enc_index(opt->ext.enc.name); |
There was a problem hiding this comment.
This is the wrong place to set this, but just a proof-of-concept
There was a problem hiding this comment.
okok so this is a weird one.
When not using Prism, opt->ext.enc.name is set by proc_K_option(), but not index:
Lines 1322 to 1324 in efa4ec0
Then, later on in load_file_internal(), the index is updated from the name, but only if no_ext_enc is true:
Lines 2703 to 2705 in efa4ec0
I tried modifying proc_K_option() to set both of these, but that doesn't work because it can't access the no_ext_enc variable to only set it conditionally.
This split source of truth (and that they aren't always perfectly in sync) is pretty confusing!
There was a problem hiding this comment.
Copied the no_src_enc/no_ext_enc/no_int_enc logic exactly as-is from load_file_internal(). Would be nice to eventually clean up this split source of truth.
ac2cb37 to
1f640eb
Compare
This comment has been minimized.
This comment has been minimized.
494393d to
1c025f0
Compare
1c025f0 to
d722e7f
Compare
#! parsing#!
#!#!)
Fix the first of the two assertion failures here:
(The latter was fixed in ruby/prism#3007)
Fixes ruby/prism#2996