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

Odd type-checking fail with generic function parameters #2

Open
bojidar-bg opened this issue Oct 30, 2023 · 0 comments
Open

Odd type-checking fail with generic function parameters #2

bojidar-bg opened this issue Oct 30, 2023 · 0 comments

Comments

@bojidar-bg
Copy link

Reproduction:

// Setup, a generic type and a few helper nodes
type Gen(Element: @Type)
type Normal
node del(
  value!: Normal
  ------
)
node normal(
  ------
  value!: Normal,
)
node passGen(
  valueIn!: Gen('A)
  ------
  valueOut: Gen('A)
)

// As a node, typechecks perfectly:
node testNode(
  paramGen: Gen(Normal),
  paramNormal!: Normal
  ------
  out: Gen(Normal),
)
rule testNode(paramGen, paramNormal!, out) normal(value!) {
  let paramNormal = normal()

  del(paramNormal)
  let variable = passGen(paramGen)

  @connect(variable, out)
}

// As a function, fails to typecheck: (observe that the types and body are the same; the node just needs a few extra wrapper lines)
function testFunction(paramGen: Gen(Normal), paramNormal: Normal): Gen(Normal) {

  del(paramNormal) // <- I fail to unify types -- left: Normal | right: Normal Gen
  let variable = passGen(paramGen)

  return variable
}

Link to playground

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