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

Top-level Dafny namespace collides with Dafny runtime #141

Open
alex-chew opened this issue Sep 18, 2023 · 2 comments
Open

Top-level Dafny namespace collides with Dafny runtime #141

alex-chew opened this issue Sep 18, 2023 · 2 comments

Comments

@alex-chew
Copy link
Contributor

alex-chew commented Sep 18, 2023

Dafny files in the src/dafny directory define modules as Dafny.* (e.g. Dafny.FileIO). But because the Dafny runtime also uses Dafny as a top-level namespace, compiling these Dafny files into Golang results in Go module name collisions (when the Go code compiled from Dafny, is passed to the Go compiler):

$ dafny build --target:go src/dafny/FileIO/FileIO.dfy
src/dafny/FileIO/FileIO-go/src/System_/System_.go:7:3: found packages Dafny (dafny.go) and dafny (dafnyFromDafny.go) in /<snip>/src/dafny/FileIO/FileIO-go/src/dafny
src/dafny/FileIO/FileIO-go/src/FileIO.go:10:3: found packages Dafny (dafny.go) and dafny (dafnyFromDafny.go) in /<snip>/src/dafny/FileIO/FileIO-go/src/Dafny
@alex-chew
Copy link
Contributor Author

Instead of unifying the Dafny code in this repo under the Dafny namespace/module, we might want to use a name like Dafny.Lib or similar. In the same vein, we might also consider changing the Dafny runtime to use a namespace like Dafny.Runtime or similar (though perhaps the Dafny runtime is the most "deserving" of the unqualified Dafny namespace... but then again doing so would probably prevent similar issues down the line.)

Also, even though unifying library code under a single namespace is a good idea, and we'll want to keep the documentation that's been added in the src/dafny tree, we should be wary of having a second copy of the code without mechanisms to ensure it stays in sync and is maintained to our quality standards.

@MikaelMayer
Copy link
Member

Good remarks.
In a test branch, I'm also using a copy of the C# runtime in DafnyCore itself but in C#, namespaces don't conflict as in Go. Moreover, we use the namespace Microsoft.Dafny whereas the runtime can be accessed using global::Dafny.

Could this issue just be fixed in Go so that every other language does not have to deal with two different namespaces?

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

No branches or pull requests

2 participants