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

Syntax error on heredoc inside block indented with tabs #989

Closed
bquorning opened this issue Jan 12, 2024 · 5 comments · Fixed by #990
Closed

Syntax error on heredoc inside block indented with tabs #989

bquorning opened this issue Jan 12, 2024 · 5 comments · Fixed by #990

Comments

@bquorning
Copy link

bquorning commented Jan 12, 2024

An error report in rubocop-rspec led me all the way via rubocop-ast into this gem. I wrote the following test case for test/test_parser.rb, and it fails (seemingly in all ruby versions and not just 3.3.0 as in the linked issue) with Parser::SyntaxError: (2.3) unterminated string meets end of file

  def test_parser_of_heredoc_inside_block_with_tab_indentation
    assert_parses(
      s(:block,
        s(:send, nil, :foo),
        s(:args),
        s(:str, "bar\n")),
      %Q{foo do!\t<<~DESC!\t\tbar!\tDESC!end}.gsub('!', "\n"),
      %q{},
      SINCE_2_3)
  end
@AlexWayfer
Copy link

With Ruby 3.2 RuboCop gives such output (not breaking itself at least):

> bundle exec rubocop
Inspecting 8 files
...F...F

Offenses:

lib/static_files_toys/template.rb:10:18: F: Lint/Syntax: unterminated string meets end of file
(Using Ruby 3.0 parser; configure using TargetRubyVersion parameter, under AllCops)
		GREP_OPTIONS = <<~STR.chomp
                 ^
static_files_toys.gemspec:12:23: F: Lint/Syntax: unterminated string meets end of file
(Using Ruby 3.0 parser; configure using TargetRubyVersion parameter, under AllCops)
	spec.description   = <<~DESC
                      ^

8 files inspected, 2 offenses detected

@iliabylich
Copy link
Collaborator

Thanks for reporting, that's definitely a regression introduced in 3.3.0.0, I'll make a fix soon.

@AlexWayfer
Copy link

I can confirm that version 3.3.0.3 fixes the problem. Great thank you.

@iliabylich
Copy link
Collaborator

parser 3.3.0.3 has been released (and it seems to fix the issue, thanks @AlexWayfer )

@bquorning
Copy link
Author

Thank you for the quick fix ❤️

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

Successfully merging a pull request may close this issue.

3 participants