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!: Disable automatically mapping a Dafny string to a Go string in externs #3647

Merged
merged 12 commits into from
Feb 28, 2023

Conversation

robin-aws
Copy link
Member

@robin-aws robin-aws commented Feb 27, 2023

Fixes #2989. From my comments on that issue:

The root cause is that the Go compiler tries to special-case extern declarations that accept or return string values, attempting to directly map the Dafny string type to the native Go string type, and coerce between them. The problem is that the SpecialNativeType subclass of UserDefinedType used to represent the native Go string type doesn't have all the expected values for a resolved type, which caused the above assertion failure if assertions are checked. In the release build, the symptom is just failing to recognize that two types are actually the same.

For the record, the root cause here is that this feature is not deeply and rigorously implemented, and to my knowledge none of the other compilers attempt to support this style of automatic equivalence of types for externs. My strong preference is to remove the implementation, being as careful as necessary about the fact that it is a breaking change.

I attempted to rewrite the one test that demonstrates this functionality (GoModule.dfy) to include manual conversions between the two string types, but I ran into several unrelated issues, and so downgraded the test to a negative test for now under Test/wishlist.

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

@robin-aws robin-aws changed the title GitHub issue 2989 fix!: Disable automatically mapping a Dafny string to a Go string Feb 27, 2023
@robin-aws robin-aws changed the title fix!: Disable automatically mapping a Dafny string to a Go string fix!: Disable automatically mapping a Dafny string to a Go string in externs Feb 27, 2023
@robin-aws robin-aws marked this pull request as ready for review February 27, 2023 23:47
alex-chew
alex-chew previously approved these changes Feb 28, 2023
@robin-aws robin-aws merged commit 66cf8dd into dafny-lang:main-4.0 Feb 28, 2023
robin-aws added a commit that referenced this pull request Mar 8, 2023
Updating `master` to pick up all `main-4.0`-specific changes (mostly
switching default option values)

The only two merge conflicts were:

1. `SinglePassCompiler.cs` - non-conflict between #3546 and #3647
touching adjacent lines.
2. `lit.sit.cfg` - slight conflict between #3662 improving the search
for Z3 and 4.0 making it only search for 4.12.1.
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.

None yet

2 participants