GridTools/gt4py

next: missing check for capturing fields in programs/field_operators

nfarabullini opened this issue · 1 comments

fields within decorator functions have to be declared as inputs, i.e. these cases are not allowed:

        field = gtx.as_field([cases.IDim], np.ones((10,), dtype=gtx.int32))

        @gtx.field_operator(backend=cartesian_case.executor)
        def field_op():
            return new_field
       @gtx.field_operator(backend=cartesian_case.executor)
       def field_op():
           return module_import.new_field

They user-facing error should be something like "Capturing new_field of type FieldType is not allowed. It needs to be passed explicitly to the GT4Py program."
The errors for other things like non-const scalars should be similar (exception is FrozenNamespace and possibly in the future scalars that are marked final).