-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix printing of generic function parameters (#516)
Fixes #482
- Loading branch information
Showing
4 changed files
with
26 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from guppylang.tys.builtin import array_type_def | ||
from guppylang.tys.param import ConstParam, TypeParam | ||
from guppylang.tys.ty import ( | ||
FunctionType, | ||
FuncInput, | ||
NumericType, | ||
OpaqueType, | ||
InputFlags, | ||
) | ||
|
||
|
||
def test_generic_function_type(): | ||
ty_param = TypeParam(0, "T", can_be_linear=True) | ||
len_param = ConstParam(1, "n", NumericType(NumericType.Kind.Nat)) | ||
array_ty = OpaqueType([ty_param.to_bound(0), len_param.to_bound(1)], array_type_def) | ||
ty = FunctionType( | ||
params=[ty_param, len_param], | ||
inputs=[FuncInput(array_ty, InputFlags.Inout)], | ||
output=ty_param.to_bound(0).ty, | ||
) | ||
assert str(ty) == "forall T, n: nat. array[T, n] -> T" |