Skip to content

Commit

Permalink
feat[next]: Check fencil/program args in ITIR type inference (GridToo…
Browse files Browse the repository at this point in the history
…ls#1565)

When the new ITIR type inference was introduced this broke the code generation in icon4py. This PR adds a small assert and improves the docstring.
  • Loading branch information
tehrengruber authored Jul 2, 2024
1 parent 664ca55 commit a07a7d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/gt4py/next/iterator/type_system/inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,11 @@ def apply(
allow_undeclared_symbols: Allow references to symbols that don't have a corresponding
declaration. This is useful for testing or inference on partially inferred sub-nodes.
Preconditions:
All parameters in :class:`itir.Program` and :class:`itir.FencilDefinition` must have a type
defined, as they are the starting point for type propagation.
Design decisions:
- Lamba functions are monomorphic
Builtin functions like ``plus`` are by design polymorphic and only their argument and return
Expand Down Expand Up @@ -378,6 +383,12 @@ def apply(
if not allow_undeclared_symbols:
node = RemoveTypes().visit(node)

if isinstance(node, (itir.FencilDefinition, itir.Program)):
assert all(isinstance(param.type, ts.DataType) for param in node.params), (
"All parameters in 'itir.Program' and 'itir.FencilDefinition' must have a type "
"defined, as they are the starting point for type propagation.",
)

instance = cls(
offset_provider=offset_provider,
dimensions=(
Expand Down

0 comments on commit a07a7d0

Please sign in to comment.