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

core.exception.ArraySliceError@pegged\pegged\peg.d(1930): slice [0 .. 18446744073709551612] extends past source array of length 0 #333

Closed
ethindp opened this issue Aug 31, 2023 · 7 comments · Fixed by #334

Comments

@ethindp
Copy link

ethindp commented Aug 31, 2023

I've no idea what I'm doing wrong here, but this is incredibly confusing.

For context, I'm writing a parser for the Ada grammar, I might be misrepresenting a rule but I don't think so (this appears to be in pegged itself). I'm using v 0.4.8. Has anyone else encountered this problem?

@veelo
Copy link
Collaborator

veelo commented Aug 31, 2023

Just arrived at my hotelroom after beerconf, so I am not fit to go into much detail. But looking at the source https://github.com/PhilippeSigaud/Pegged/blob/31e02e22e075a37434354a26ef5d1dd8f58808e5/pegged/peg.d#L1930C25-L1930C25 it appears the length of errString is zero, and subtracting 4 from unsigned 0 gives you this giant index. So I would say this is a bug in Pegged, but one that is only triggered if you try to feed it an invalid grammar.

I fixed a similar error in #325. Maybe this is enough info for you to fix this by yourself, and I'll gladly accept a pull request. Otherwise I may find some time tomorrow during the DConf hackathon.

@ethindp
Copy link
Author

ethindp commented Aug 31, 2023

@veelo Wouldn't Pegged report if my grammar was invalid? I'm pre-generating the code via asModule since compiling it at build time would take quite a long time.

@veelo
Copy link
Collaborator

veelo commented Aug 31, 2023

By the way, if you get your grammar to work, it would be nice to include it as an example, if you like.

@ethindp
Copy link
Author

ethindp commented Aug 31, 2023

I'd be happy to, though I'll probably want to trim the AST a lot before I do (the AST is probably going to be pretty big).

@veelo
Copy link
Collaborator

veelo commented Sep 1, 2023

@veelo Wouldn't Pegged report if my grammar was invalid?

Yes, it is during the reporting that Pegged messes up.

veelo added a commit to veelo/Pegged that referenced this issue Sep 1, 2023
Apply same fix as in dlang-community#325.

Fixes dlang-community#333 ArraySliceError.
@veelo veelo closed this as completed in #334 Sep 1, 2023
veelo added a commit that referenced this issue Sep 1, 2023
Apply same fix as in #325.

Fixes #333 ArraySliceError.
@veelo
Copy link
Collaborator

veelo commented Sep 1, 2023

I've tagged a new release: v.0.4.9. It should show up on Dub later today. Please let me know if this resolves the problem.

@ethindp
Copy link
Author

ethindp commented Sep 1, 2023

@veelo I'll let you know if it (doesn't) work once Dub has it. Thank you!

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 a pull request may close this issue.

2 participants