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

[parser] Fix bug when printing type builder errors #6817

Merged
merged 1 commit into from
Aug 7, 2024
Merged

Conversation

tlively
Copy link
Member

@tlively tlively commented Aug 6, 2024

The type index from the TypeBuilder error was mapped to a file location
incorrectly, resulting in an assertion failure.

Fixes #6816.

The type index from the TypeBuilder error was mapped to a file location
incorrectly, resulting in an assertion failure.

Fixes #6816.
@tlively tlively requested a review from kripken August 6, 2024 22:10
@@ -34,7 +34,7 @@ Result<> parseTypeDefs(
if (auto* err = built.getError()) {
std::stringstream msg;
msg << "invalid type: " << err->reason;
return ctx.in.err(decls.typeDefs[err->index].pos, msg.str());
return ctx.in.err(decls.subtypeDefs[err->index].pos, msg.str());
Copy link
Member

@kripken kripken Aug 6, 2024

Choose a reason for hiding this comment

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

Why is this correct? I'm not sure how I would have known to think this was wrong. We are in parseTypeDefs, so shouldn't the typeDefs be relevant..? We even loop over typeDefs on line 29.

Copy link
Member Author

Choose a reason for hiding this comment

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

Each entry in typeDefs corresponds to a single recursion group (which may consist of a single top-level type definition without (rec...), whereas each entry in subtypeDefs corresponds to a single type definition, which may or may not actually contain (sub ...).

Better names would perhaps be recTypeDefs and typeDefs rather than typeDefs and subtypeDefs. Do you think it's worth updating those names here or in a separate PR?

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks. Either way sgtm. lgtm as is if you prefer separately.

@tlively tlively merged commit 23a1a1a into main Aug 7, 2024
13 checks passed
@tlively tlively deleted the parser-subtype-bug branch August 7, 2024 00:01
@gkdn gkdn mentioned this pull request Aug 31, 2024
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.

Wat parser assertion on invalid subtype
2 participants