Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions guppylang/checker/expr_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
with_loc,
with_type,
)
from guppylang.cfg.builder import tmp_vars
from guppylang.cfg.builder import is_tmp_var, tmp_vars
from guppylang.checker.core import (
Context,
DummyEvalDict,
Expand Down Expand Up @@ -1083,7 +1083,7 @@ def check_comptime_arg(
match arg:
case PlaceNode(place=place) if place.root.is_func_input:
s = ComptimeUnknownError.InputHint(place.defined_at, place)
case PlaceNode(place=place):
case PlaceNode(place=place) if not is_tmp_var(place.root.name):
s = ComptimeUnknownError.VariableHint(place.defined_at, place)
case arg:
s = ComptimeUnknownError.FallbackHint(arg)
Expand Down
16 changes: 16 additions & 0 deletions tests/error/comptime_arg_errors/unknown_cf_expr.err
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Error: Not known at compile-time (at $FILE:12:15)
|
10 | @guppy
11 | def main(b: bool) -> nat:
12 | return foo(nat(1) if b else nat(2))
| ^^^^^^^^^^^^^^^^^^^^^^^ Value of this argument must be known at compile-time
|
12 | return foo(nat(1) if b else nat(2))
| ----------------------- This expression involves a dynamic computation, so its value
| is not statically known

Note: We are currently investigating ways to make Guppy's compile-time reasoning
smarter. Please leave your feedback at
https://github.com/CQCL/guppylang/discussions/987

Guppy compilation failed due to 1 previous error
15 changes: 15 additions & 0 deletions tests/error/comptime_arg_errors/unknown_cf_expr.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from guppylang import guppy
from guppylang.std.builtins import comptime, nat


@guppy
def foo(n: nat @comptime) -> nat:
return n


@guppy
def main(b: bool) -> nat:
return foo(nat(1) if b else nat(2))


guppy.compile(main)
Loading