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

Fix "singleton overload" check for user lists #4129

Merged
merged 8 commits into from
Mar 26, 2024

Conversation

Baltoli
Copy link
Contributor

@Baltoli Baltoli commented Mar 25, 2024

When working on #4045, I identified a case in the C Semantics where an overload set was flagged as being singletons (that is, that the productions in the set were not actually overloads of one another). Despite this warning, removing the overload(_) attributes broke compilation by producing a parsing ambiguity.

It turns out that the issue was a difference between the main module and the disambiguation module produced during the inner parsing process. The disambiguation module adds an additional production

Es ::= E

for user list sorts Es that subsorts the list element sort into the list sort. This means that two productions

S ::= f(Es)
T ::= f(E)

can be overloads of one another.

However, this check was only using the overloads induced by the main module and not those used by the disambiguation module. The fix is simply to compute the disambiguation module1 and use its overloads for the checks. Doing so requires some changes to the plumbing; the subsorting production is previously only added when RULE-LISTS is imported, but we need to short-circuit that code path in this context.

This PR includes a regression test minimised from the original example.

Footnotes

  1. I tried a cheaper fix that just checks parameters of overload-attributed productions to see if they appear in a user list, but this isn't sufficiently general in the case where the overload parameter is actually a sub-/supersort of the user list element, as happens in the C semantics.

@Baltoli Baltoli marked this pull request as ready for review March 25, 2024 19:19
@Baltoli Baltoli requested review from tothtamas28 and gtrepta March 25, 2024 19:19
@Baltoli
Copy link
Contributor Author

Baltoli commented Mar 26, 2024

Related: #1278

@Baltoli Baltoli mentioned this pull request Mar 26, 2024
8 tasks
@rv-jenkins rv-jenkins merged commit af88266 into develop Mar 26, 2024
8 checks passed
@rv-jenkins rv-jenkins deleted the fix-disambiguation-singleton branch March 26, 2024 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants