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

Adds failing spec #601

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Adds failing spec #601

wants to merge 1 commit into from

Conversation

davidwessman
Copy link
Collaborator

@davidwessman davidwessman commented Oct 20, 2024

It took a while for me to find the correct error case, but this key is invalid when parsed by the PatternWithScopeScanner causing the errors in #520

@glebm any suggestion for regex to fix this?

Failure/Error: expect(scanner.keys.map(&:key)).to eq(['test.N#{n["key"]}'])
     
       expected: ["test.N\#{n[\"key\"]}"]
            got: ["test.N\#{n["]
     
       (compared using ==)
     # ./spec/pattern_with_scope_scanner_spec.rb:91:in `block (3 levels) in <top (required)>'

@glebm
Copy link
Owner

glebm commented Oct 20, 2024

This may be tricky to fix with a regex.

Currently it is defined here:

LITERAL_RE = /:?".+?"|:?'.+?'|:\w+/.freeze

A possible workaround is to dissallow letters and ] immediately after the ".
This can be done using a negative lookahead, e.g.:

LITERAL_RE = /^:?(["']).+?\1(?![\p{L}\]])|:\w+/.freeze

https://rubular.com/r/g77VbORrgrqZdx

Disallowing ] would mean the following contrived example would fail though:

[t 'a.b.c']

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 this pull request may close these issues.

2 participants