Skip to content

test_unlisted_construct_falls_back_to_ast_name does not exercise the fallback path #2759

Description

@egparedes

In tests/next_tests/unit_tests/ffront_tests/test_diagnostic_messages.py:

def test_unlisted_construct_falls_back_to_ast_name():
    def with_string(a: gtx.Field[[IDim], float64]) -> gtx.Field[[IDim], float64]:
        f"{a}"
        return a

    err = parse_error(with_string)

    assert isinstance(err, errors.UnsupportedPythonFeatureError)
    assert "f-string" in err.message

The test name claims it covers the generic fallback in _describe_unsupported_feature (ffront/dialect_parser.py), which names the qualified ast class for constructs that are not in _UNSUPPORTED_FEATURE_HINTS. But ast.JoinedStr is in the catalogue:

ast.JoinedStr: ("f-string", ("Strings cannot be computed inside GT4Py functions.",)),

so the assertion "f-string" in err.message passes via the catalogue, not via the fallback. The fallback branch is currently untested, and the test name is misleading about what it guards.

Suggested fix

Either:

  • point the test at a construct genuinely absent from the catalogue, so the f"{module}.{qualname}" fallback is exercised, and keep a separate test for the catalogued f-string message; or
  • rename the test to reflect that it pins the catalogued f-string diagnostic.

The first is preferable — the fallback is what keeps the parser from regressing when CPython adds node types, which is the property the catalogue design depends on.

Found while removing the Python 3.10 shims in #2755.

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-foundIssues found by agents and need triage. Remove the label once the issue is human confirmed.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions