guppylang
guppylang copied to clipboard
`nat @ comptime` argument not recognised in nested function signature
When using a nat @ comptime in the signature of a nested function, the variable is not defined
@guppy
def foo(n: nat @ comptime) -> None:
@guppy
def bar(arr: 'array[nat, n]') -> None:
pass
gives n is not defined
Thanks for reporting! Currently, nested functions can't refer to parameters from the outside, but I agree this would be nice addition. Created issue #1050 to track this.
For now, you should be able to get away with defining bar outside of foo:
n = guppy.nat_var("n")
@guppy
def _bar(arr: 'array[nat, n]') -> None:
pass
@guppy
def foo(n: nat @ comptime) -> None:
bar = _bar[n]