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

Some bugfixes #3564

Closed
wants to merge 2 commits into from
Closed

Some bugfixes #3564

wants to merge 2 commits into from

Conversation

KvanTTT
Copy link
Member

@KvanTTT KvanTTT commented Mar 2, 2022

No description provided.

g.tool.errMgr.toolError(ErrorType.INTERNAL_ERROR, "element list has first|last == null");
}
return new Handle(first.left, last.right);
Handle last = els.get(n - 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a significant change in behavior, that might break users code

Copy link
Member Author

@KvanTTT KvanTTT Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just removed first==null || last==null check, null elements are being processed later. How it could affect user code? I don't understand why it's a significant change in behavior. All tests are passing and there is no test on INTERNAL_ERROR (except for the first test added in this PR).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It no longer throws a tool error, that's a significant change.
Not sure how to reproduce the throwing scenario, but it would be better to have a test for that (which throws with the existing code) and check that it still does with the new code.
We never know what developers do with development tools, they might be sending some random grammars and expecting an error if the grammar isn't valid...

Copy link
Member Author

@KvanTTT KvanTTT Mar 2, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My test covers NPE from definite issue #2788. If I restore the check, two errors will occur:

error(20): Test.g4:2:30: internal error: Rule error undefined 
error(20):  internal error: element list has first|last == null 

The message internal error: element list has first|last == null is duplicated, completely unclear for the end-user, and does not help to resolve an issue. The first message is much more informative.

We never know what developers do with development tools, they might be sending some random grammars and expecting an error if the grammar isn't valid...

I'm almost sure there are unfixed errors in the tool but I think real issues are more important than potential ones in random grammars. We can fix them later if they occur.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not saying this is important, but not sure the first message can't be improved ? How about putting the undefined rules in quotes ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it can, but I didn't change it. This is the existing error that is being thrown in https://github.com/antlr/antlr4/blob/dev/tool/src/org/antlr/v4/automata/ParserATNFactory.java#L297 Also, it looks like we don't use quotes for other similar errors, see for example

UNDEFINED_RULE_REF(56, "reference to undefined rule: <arg>", ErrorSeverity.ERROR),

@parrt
Copy link
Member

parrt commented Mar 26, 2022

Hi. I think I will close this because as I mentioned I'm not a big fan of removing IFs in favor of ?: and I can't risk changing the ATN factory. basically, I think I'm unlikely to accept changes to the code that are purely for the purpose of code cleanup. I'm really in maintenance mode.

@parrt parrt closed this Mar 26, 2022
@KvanTTT
Copy link
Member Author

KvanTTT commented Apr 8, 2022

I will close this because as I mentioned I'm not a big fan of removing IFs in favor of ?:

Actually I didn't replace IF on ?:, but added a new one. Ok, I can use if everywhere if you like it.

I can rollback code style changes. But I don't see significant changes of ATN factory, I've fixed NRE that should not be thrown, it's quite important especially for plugin.

@parrt
Copy link
Member

parrt commented Apr 8, 2022

Hi. please roll back to avoid style changes so that I can see the actual changes. :) then I can take a quickly look :)

@KvanTTT
Copy link
Member Author

KvanTTT commented Apr 8, 2022

It's already done :) #3632

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.

3 participants