Skip to content

Commit

Permalink
Merge pull request #404 from Shopify/rm-fix-prism
Browse files Browse the repository at this point in the history
Fix error when parsing ERB files with yield on the top level
  • Loading branch information
rafaelfranca authored May 2, 2024
2 parents 23f31a3 + 9c1f699 commit f287144
Show file tree
Hide file tree
Showing 5 changed files with 13,211 additions and 7,263 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
- gemfiles/Gemfile-rails-6-0
- gemfiles/Gemfile-rails-6-1
ruby:
- "2.7"
- "3.0"
- "3.1"
- "3.2"
Expand All @@ -40,7 +39,6 @@ jobs:
gemfile:
- Gemfile
ruby:
- "2.7"
- "3.0"
- "3.1"
- "3.2"
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PATH
constant_resolver (>= 0.2.0)
parallel
parser
prism (>= 0.24.0)
prism (>= 0.25.0)
sorbet-runtime (>= 0.5.9914)
zeitwerk (>= 2.6.1)

Expand Down Expand Up @@ -77,7 +77,7 @@ GEM
ast (~> 2.4.1)
racc
prettier_print (0.1.0)
prism (0.24.0)
prism (0.27.0)
racc (1.7.1)
rack (2.2.4)
rack-test (2.0.2)
Expand Down
7 changes: 7 additions & 0 deletions lib/packwerk/parsers/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ def initialize(builder)
super(builder)
super.diagnostics.all_errors_are_fatal = true
end

private

sig { params(error: Prism::ParseError).returns(T::Boolean) }
def valid_error?(error)
error.type != :invalid_yield
end
end

class TolerateInvalidUtf8Builder < Parser::Builders::Default
Expand Down
2 changes: 1 addition & 1 deletion packwerk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Gem::Specification.new do |spec|
# For Ruby parsing
spec.add_dependency("ast")
spec.add_dependency("parser")
spec.add_dependency("prism", ">= 0.24.0") # 0.24.0 fixes a performance issue with the parser translator
spec.add_dependency("prism", ">= 0.25.0")

# For ERB parsing
spec.add_dependency("better_html")
Expand Down
Loading

0 comments on commit f287144

Please sign in to comment.