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

[Ruby] Failure to properly match correctly balanced code #638

Closed
metatron-the-chronicler opened this issue Aug 18, 2016 · 1 comment
Closed

Comments

@metatron-the-chronicler

Given the following code

module Rfmt
    module Rewriters
        class AlignEq < Parser::Rewriter
            def on_begin(node)
                eq_nodes = []

                node.children.each do |child_node|
                    if assignment?(child_node)
                        eq_nodes << child_node
                    elsif eq_nodes.any?
                        align(eq_nodes)
                        eq_nodes = []
                    end
                end

                align(eq_nodes)

                super
            end

            def align(eq_nodes)
                aligned_column = eq_nodes.
                      map { |node| node.loc.operator.column }.
                      max

                eq_nodes.each do |node|
                    if(column = node.loc.operator.column) < aligned_column
                        insert_before node.loc.operator, ' ' * (aligned_column - column)
                    end
                end
            end
        end
    end
end

I get the following error:

Search failed. This means there is unmatched expression somewhere or we are at the beginning/end of file.

Issue #514 may be related as well.

Note that this code does use tabs.

@Fuco1 Fuco1 modified the milestone: 1.10 Sep 25, 2016
@Fuco1
Copy link
Owner

Fuco1 commented Jan 4, 2017

Right, using spaces this parses fine, so I suppose there's some broken regexp somewhere which only uses space and not whitespace.

@Fuco1 Fuco1 closed this as completed in 199006a Jan 4, 2017
jojojames pushed a commit to jojojames/smartparens that referenced this issue Mar 31, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants