Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line number is incorrect for interpolation inside heredoc #7272

Open
judofyr opened this issue Jul 18, 2022 · 6 comments
Open

Line number is incorrect for interpolation inside heredoc #7272

judofyr opened this issue Jul 18, 2022 · 6 comments

Comments

@judofyr
Copy link

judofyr commented Jul 18, 2022

Script:

def __tilt_4000
<<TILT1596320670.chomp
<html>
<body>
<h1>Hey #{name}!</h1>
TILT1596320670
end

__tilt_4000

Environment Information

$ jruby -v
jruby 9.3.3.0 (2.6.8) 2022-01-19 b26de1f5c5 OpenJDK 64-Bit Server VM 18+0 on 18+0 +jit [darwin-x86_64]
$ uname -a
Darwin sam.home 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

Expected Behavior

The error is reported at line 5:

$ /usr/bin/ruby t.rb
t.rb:5:in `__tilt_4000': undefined local variable or method `name' for main:Object (NameError)
	from t.rb:9:in `<main>'

Actual Behavior

The error is reported where the heredoc starts:

$ jruby t.rb
NameError: undefined local variable or method `name' for main:Object
  __tilt_4000 at t.rb:2
       <main> at t.rb:9
@enebo
Copy link
Member

enebo commented Feb 2, 2023

method_missing is issuing this but the #{name} processing must not be emitting a linenum instr. I think. Also affects 9.4.x

@headius
Copy link
Member

headius commented Sep 10, 2023

Still valid in both 9.3 and 9.4 HEAD, but won't be fixed for 9.3.11.

@headius
Copy link
Member

headius commented Feb 9, 2024

@judofyr Dunno if you are still out there, but this would be a great addition to ruby/spec. Could you write up a quick PR?

Moving to 9.5 since this probably will get fixed in the move to Prism.

@headius headius modified the milestones: JRuby 9.3.14.0, JRuby 9.5.0.0 Feb 9, 2024
judofyr added a commit to judofyr/ruby-spec that referenced this issue Feb 10, 2024
@judofyr
Copy link
Author

judofyr commented Feb 10, 2024

@judofyr Dunno if you are still out there, but this would be a great addition to ruby/spec. Could you write up a quick PR?

Moving to 9.5 since this probably will get fixed in the move to Prism.

Like this ruby/spec#1135?

@judofyr
Copy link
Author

judofyr commented Feb 10, 2024

While writing the test I also discovered that it only happens if you have the .chomp there. Without it it passes.

@headius
Copy link
Member

headius commented Feb 10, 2024

@judofyr:

Like this ruby/spec#1135?

Great! I will comment there with some small suggestions.

While writing the test I also discovered that it only happens if you have the .chomp there.

Ah interesting. So it is wiping out the line numbers in the heredoc when it has other code following the opening tag. Perhaps that will help @enebo to fix this.

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants