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

generates code with invalid generics when calling helper functions #29

Open
glennhartmann opened this issue May 19, 2024 · 0 comments
Open

Comments

@glennhartmann
Copy link

The following borgo code:

use fmt

struct foo<T> {
    val: T
}

impl<T> (f: foo<T>) {
    fn print() {
        printHelper(f)
    }
}

fn printHelper<T>(f: foo<T>) {
    fmt.Println(f.val)
}

fn main() {
    let f = foo{val: 5}
    f.print()
}

generates:

package main
import (
 "fmt"
)

type foo[T any] struct {
  val T
}
 func (f foo[T]) print  ()  {


 printHelper[any](f)
}
 func  printHelper [T any] (f foo[T])  {


 fmt.Println(f.val)
}
 func  main  ()  {


f := foo[int] { val: 5,  }

 f.print()
}

The issue here is that the line that reads printHelper[any](f) should read printHelper[T](f).

I can't find a way to get borgo to generate compiling Go code for this case.

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

1 participant