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

Running prettier twice on the same file crashes #75

Closed
AlanFoster opened this issue Feb 11, 2019 · 1 comment
Closed

Running prettier twice on the same file crashes #75

AlanFoster opened this issue Feb 11, 2019 · 1 comment

Comments

@AlanFoster
Copy link
Contributor

AlanFoster commented Feb 11, 2019

Input

https://github.com/rails/rails/blob/9099d66bc38f2e560613258f520d46df624d99c0/activesupport/lib/active_support/configurable.rb

Current output

       # Compiles reader methods so we don't have to go through method_missing.
       def self.compile_methods!(keys)
         keys.reject { |m| method_defined?(m) }.each do |key|
-          class_eval <<-RUBY, __FILE__, __LINE__ + 1
-            def #{key}; _get(#{key.inspect}); end
-          RUBY
+          class_eval <<-RUBY
+                                 def #{key}; _get(#{key
+                       .inspect}); end
+          RUBY,
+                     __FILE__,
+                     __LINE__ + 1
         end
       end
     end

Note that this code crashes when running prettier again on the same file:

src/ripper.rb:33:in block in parse': undefined method []' for nil:NilClass (NoMethodError)

Expected output

Not to crash

Reproduction

Run prettier with --write twice on the Rail's file, or once with --debug-check

yarn prettier --debug-check --plugin=. --parser=ruby ../rails/activesupport/lib/active_support/configurable.rb

@kddnewton
Copy link
Member

Yeah, this is the same as #50 - we've gotta address heredoc handling. Gonna close this as a dup of that one

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

2 participants