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

Modules with extern names containing periods produce malformed Go code #2045

Closed
robin-aws opened this issue Apr 22, 2022 · 2 comments · May be fixed by #2952
Closed

Modules with extern names containing periods produce malformed Go code #2045

robin-aws opened this issue Apr 22, 2022 · 2 comments · May be fixed by #2952
Assignees
Labels
lang: golang Dafny's transpiler to Go and its runtime part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag

Comments

@robin-aws
Copy link
Member

module {:extern "A.B"} A.B {}
$ dafny src/Scratch.dfy /compileTarget:go

Dafny program verifier finished with 0 verified, 0 errors
Wrote textual form of target program to Scratch-go/src/Scratch.go
Additional target code written to Scratch-go/src/dafny/dafny.go
Additional target code written to Scratch-go/src/System_/System_.go
Additional target code written to Scratch-go/src/A_Compile/A_Compile.go
src/Scratch-go/src/Scratch.go:7:4: expected 'STRING', found '.'

Scratch.go contains:

// Dafny program Scratch.dfy compiled into Go
package Scratch

import (
  _dafny "dafny"
  _System "System_"
  A.B "A.B"
  A_Compile "A_Compile"
)
var _ _dafny.Dummy__
var _ _System.Dummy__
var _ A_Compile.Dummy__

Arguably this isn't a bug, because this is literally the symbol the user asked for. The intent is just to disable the name mangling that normally adds _Compile, though. The given external name works for other target languages, and there doesn't seem to be a way to preserve the original name that does work for Go.

@robin-aws robin-aws added part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag lang: golang Dafny's transpiler to Go and its runtime labels Apr 22, 2022
@robin-aws robin-aws self-assigned this Jul 8, 2022
@cpitclaudel
Copy link
Member

Note that you can write module {:extern "A", "A.B"} A.B {}, which produces A "A.B"

@robin-aws
Copy link
Member Author

Apologies for leaving this open: we decided that it wasn't reasonable to expect a single {:extern} attribute to work over multiple languages, so this isn't a bug. See #4322 for a related feature we added instead.

@robin-aws robin-aws closed this as not planned Won't fix, can't repro, duplicate, stale Nov 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang: golang Dafny's transpiler to Go and its runtime part: code-generation Support for transpiling Dafny to another language. If relevant, add a `lang:` tag
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants