-
Notifications
You must be signed in to change notification settings - Fork 269
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
[Bug]: Go compiler can't convert extern string to seq<char> #2989
Comments
When attempting to reproduce this with a debug source build, I actually hit an exception:
The root cause is that the Go compiler tries to special-case extern declarations that accept or return |
Ah, good catch. I'd seen this while trying to debug, but didn't realize it only appeared with a debug build - I was trying to reproduce this error in the VSCode IDE to no avail. |
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've flagged this as a breaking change and conservatively added it to the Dafny 4.0 milestone in case we treat it as such. @hmijail is any of your code depending on this behavior at this point, or would it benefit from the more consistent behavior of a Dafny |
We're just getting started with the Go part, so we don't really care at this point. |
…externs (#3647) 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`.
Dafny version
3.9.1.41027
Code to produce this issue
Command to run and results
What happened?
A call to an extern method returning a
string
, is not successfully compiled to Golang. The compiler complains that itCannot convert from string to seq<char>
. The same code compiles as expected to C#, Java, Javascript, and Python.The same happens if the extern method is declared to return
seq<char>
, which is unsurprising since it is synonymous withstring
, but then again this seems to matter to the Golang compiler.What type of Operating System are you seeing the problem on?
Mac
The text was updated successfully, but these errors were encountered: