Skip to content

fix: handle slice literals without named types #635

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

Merged
merged 3 commits into from
Mar 21, 2024
Merged

fix: handle slice literals without named types #635

merged 3 commits into from
Mar 21, 2024

Conversation

a-h
Copy link
Owner

@a-h a-h commented Mar 20, 2024

Fixes #626

@joerdav
Copy link
Collaborator

joerdav commented Mar 20, 2024

This all makes complete sense, though I have some test cases that might require some minor changes. Quite niche scenarios too.

{
	name: "function call with array of explicit length",
	input: `tabs([2]TabData{
  {Name: "A"},
  {Name: "B"},
})`,
},
{
	name: "function call with array of inferred length",
	input: `tabs([...]TabData{
  {Name: "A"},
  {Name: "B"},
})`,
},

@joerdav
Copy link
Collaborator

joerdav commented Mar 20, 2024

Oh! I expected that to fail because of:

if ep.Previous == token.LBRACK && tok == token.RBRACK {

Maybe I need to read the PR again...

@a-h
Copy link
Owner Author

a-h commented Mar 20, 2024

Those additional cases don't appear to require any changes, because it's hitting the logic that if there's an open [, anything until the next ] is OK.

@joerdav
Copy link
Collaborator

joerdav commented Mar 21, 2024

Cool, racked my brain and can't think of any more scenarios. Re-read the code with a fresh brain, and it all makes sense now.

@joerdav joerdav merged commit 1e176a0 into main Mar 21, 2024
@a-h
Copy link
Owner Author

a-h commented Mar 21, 2024

Thanks for thinking about it, that's half the battle. :)

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.

parser: Error with slice literal on v0.2.639
2 participants