Skip to content

Fold builtin calls on the authored literal, not the coerced one #373

Description

@e54-bot

Parent: #366. Found by the builtin probe in #370 (gap fold-after-coercion).

Goal

Make builtin folds see the literal the author wrote, as the pinned OverPy 9.7.10 does, instead of the parameter's canonical form.

Context

Lowering rewrites False, True, 0 and an empty array to the parameter's canonical form (normalize_value_with_coercions in compiler/lowering.rs) before optimization. A fold on the rewritten value then differs from the reference, which folds on what was written: min(false, 3) folds to 0 natively but stays Min(False, 3); [1, 2].index(0) keeps Null natively but folds to -1; hudText(..., [], ...) becomes Null; .replace, .slice behave alike. 38 probes (6 functions) differ; after workshop-rs 0.6.4 parsing treats the coercible spellings as one structure, so only the folds show.

Scope

  • Apply the coercions after optimization, or stop applying them where the validator now accepts the authored form, without changing the structure of currently converged output.
  • Oracle-backed fixtures for the folds above.

Non-goals

  • Changing workshop-rs.

Acceptance criteria

  • The fold-after-coercion gap is removed from tools/overpy/probe-gaps.json.
  • Existing integration_tests and the corpus stay green (12 semantic-equivalence tests depend on today's normalization).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions