guppylang icon indicating copy to clipboard operation
guppylang copied to clipboard

Allow nested functions to refer to type parameters of the outer function

Open mark-koch opened this issue 6 months ago • 2 comments

@guppy
def main[T]() -> None:
    def bar() -> None:
        x: Option[T] = nothing()

This should also fix #1036.

To do this, the inner function should inherit all type params of the outer function. Then we immediately type-apply the bound variables of the outer function

mark-koch avatar Jun 24 '25 08:06 mark-koch

  • This is very hard, that's why we didn't do it
  • We don't have nested functions anymore

doug-q avatar Jun 24 '25 08:06 doug-q

I'm not suggesting any change to Hugr, this should be a pure frontend feature

mark-koch avatar Jun 24 '25 09:06 mark-koch