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

Golang: Skip ghost parameters in type parameter downcast #5815

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ private ConcreteSyntaxTree CreateSubroutine(string name, List<TypeArgumentInstan
for (var i = 0; i < inParams.Count; i++) {
var p = (overriddenInParams ?? inParams)[i];
var instantiatedType = p.Type.Subst(thisContext.ParentFormalTypeParametersToActuals);
if (!instantiatedType.Equals(p.Type)) {
if (!p.IsGhost && !instantiatedType.Equals(p.Type)) {
// var p instantiatedType = p.(instantiatedType)
var pName = IdName(inParams[i]);
DeclareLocalVar(pName, instantiatedType, p.tok, true, null, w);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %testDafnyForEachCompiler "%s"

trait MyTrait<T> {
method Bar(ghost x: T, y: T) returns (z: T)
}

class MyClass extends MyTrait<int> {
constructor() {}
method Bar(ghost x: int, y: int) returns (z: int) {
return y;
}
}

method Main() {
var c := new MyClass();
var z := c.Bar(7, 42);
expect z == 42;
}