-
Notifications
You must be signed in to change notification settings - Fork 145
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
[K-Bug] Uncaught exception thrown of type NegativeArraySizeException #4592
Comments
I believe I have identified the cause of this issue. The line:
is desugared to
This results in the scanner assigning a kind of From my investigation, the root cause seems to be in the UserList.java file, where the separator is being trimmed: public UserList(Sort sort, String separator) {
this.sort = sort;
this.separator = separator.trim();
this.listType = ZERO_OR_MORE;
}
public UserList(Sort sort, String separator, String listType) {
this.sort = sort;
this.separator = separator.trim();
this.listType = listType;
} Wouldn't it be better to leave the separator as it is instead of trimming it? |
Huh, this is an interesting corner case I believe. Usually, we are counting on all whitespace to be deleted because of the So with default I'm tempted to say we just shouldn't trim at all, like you said. My guess is that this trimming was to prevent the case where we had users write Maybe we can get rid of this trim, but also have a check up front for all list-separator productions, to see if they intersect with any |
I agree this is the right approach! We'll need to implement a translation to the |
I think for now we can probably remove the |
I noticed that in K v7.1.116, the However, I have a follow-up question: I couldn't find a way to match |
@pxhdev You're correct - the newline gets discarded. Normally To work around this, and other similar inner parsing issues, every syntax production in K has an associated name called its the "symbol" or "klabel", which you can set with the
Rather than writing the production directly, you can instead refer to it by surrounding the symbol with backticks, so
is the same as
For
is desugared under-the-hood to
Your rule would then be written like
Let us know if this is unclear or if you run into any further issues! |
Update: I think this could be solved by introducing a new layer:
This seems slightly different from lists. My original code looks like this:
When I fetch the first element of the list, I can specify a particular subtype.
It seems to only accept
|
Everything works. Your explanation is really clear and helpful. Thank you soooooo much! |
What component is the issue in?
Front-End
Which command
What K Version?
K version: v7.1.106 Build date: Thu Aug 15 01:22:33 CST 2024
Operating System
Linux
K Definitions (If Possible)
Steps to Reproduce
kompile the definition and try parsing the newline.txt
The error message:
Expected Results
kast successfully parses the file.
The text was updated successfully, but these errors were encountered: