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 Cycle in type declaration causes crash (#4471) #5153

Merged
merged 3 commits into from
Mar 8, 2024
Merged

Conversation

ssomayyajula
Copy link
Contributor

Description

Fixes #4471, explanation here.

How has this been tested?

Tests under .../git-issues/git-issue-4471/.

By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.

@ssomayyajula ssomayyajula linked an issue Mar 6, 2024 that may be closed by this pull request
@@ -5066,8 +5066,7 @@ public record ResolveTypeReturn(Type ReplacementType, ExprDotName LastComponent)
if (lax) {
// we have to be careful about uses of the type being defined
var cg = enclosingTypeDefinition.EnclosingModuleDefinition.CallGraph;
var t0 = resolvedClass as ICallable;
if (t0 != null && cg.GetSCCRepresentative(t0) == cg.GetSCCRepresentative((ICallable)enclosingTypeDefinition)) {
if (resolvedClass is ICallable t0 && enclosingTypeDefinition is ICallable t1 && cg.GetSCCRepresentative(t0) == cg.GetSCCRepresentative(t1)) {
reporter.Error(MessageSource.Resolver, t.tok, "using the type being defined ('{0}') here would cause a logical inconsistency by defining a type whose cardinality exceeds itself (like the Continuum Transfunctioner, you might say its power would then be exceeded only by its mystery)", resolvedClass.Name);
Copy link
Member

Choose a reason for hiding this comment

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

It makes me happy that this change at least slightly increases the chance of users getting to see this error message. :)

@robin-aws robin-aws enabled auto-merge (squash) March 8, 2024 05:28
@robin-aws robin-aws merged commit a26195e into master Mar 8, 2024
20 checks passed
@robin-aws robin-aws deleted the 4471-fix branch March 8, 2024 18:28
atomb pushed a commit to atomb/dafny that referenced this pull request Mar 11, 2024
…ang#5153)

### Description
<!-- Is this a user-visible change? Remember to update RELEASE_NOTES.md
-->
<!-- Is this a bug fix for an issue visible in the latest release?
Mention this in the PR details and ensure a patch release is considered
-->

Fixes dafny-lang#4471, explanation
[here](dafny-lang#4471 (comment)).

### How has this been tested?
<!-- Tests can be added to
`Source/IntegrationTests/TestFiles/LitTests/LitTest/` or to
`Source/*.Test/…` and run with `dotnet test` -->

Tests under `.../git-issues/git-issue-4471/`.

<small>By submitting this pull request, I confirm that my contribution
is made under the terms of the [MIT
license](https://github.com/dafny-lang/dafny/blob/master/LICENSE.txt).</small>

Co-authored-by: Siva Somayyajula <[email protected]>
Co-authored-by: Robin Salkeld <[email protected]>
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.

Cycle in type declaration causes crash
2 participants