Skip to content

feat(opy): complete semantic HIR subroutine resolution - #149

Merged
Teakowa merged 2 commits into
mainfrom
codex/issue-143-semantic-hir
Aug 31, 2026
Merged

feat(opy): complete semantic HIR subroutine resolution#149
Teakowa merged 2 commits into
mainfrom
codex/issue-143-semantic-hir

Conversation

@e54-bot

@e54-bot e54-bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Materialize implicit subroutine declarations for def definitions with source spans.
  • Enforce source-order visibility for declarations, definitions, variables, macros, and enums.
  • Add stable duplicate diagnostics and tooling regressions for HIR symbols and provenance.
  • Update the compiler expectation for the now-successful def-containing corpus fixture while retaining its separate lowering known gap.

Verification

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --all-features -- -D warnings
  • cargo test --workspace --all-targets --all-features
  • python3 compatibility/run_native.py --binary target/debug/opy-cli --semantic-binary target/debug/opy-compat

Fixes #143

Materialize implicit subroutine declarations for def definitions, enforce source-order visibility, and expose stable diagnostics and tooling provenance.

Fixes #143

@Teakowa Teakowa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major — crates/opy-rs/src/lower.rs: current_order is derived from separate program.declarations / program.rules vector indexes, but the parser allows those top-level forms to interleave in source. This makes every declaration appear before every rule/def, so e.g. a rule can incorrectly see a variable/macro/enum declared later, while a macro can incorrectly fail to see a def written earlier. Preserve one top-level source order (or compare source positions) when enforcing visibility.

Minor — crates/opy-rs/src/lower.rs: duplicate global/player/subroutine declarations use HashMap::insert, which replaces the first declaration's order with the duplicate's order. References between the first and duplicate declarations can then produce spurious unknown-identifier/visibility failures in addition to the duplicate diagnostic. Keep the first binding/order when reporting a duplicate.

Keep declaration visibility aligned with interleaved source forms and retain first declaration order when reporting duplicates.

@Teakowa Teakowa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Teakowa
Teakowa merged commit bd7a468 into main Aug 31, 2026
5 checks passed
@Teakowa
Teakowa deleted the codex/issue-143-semantic-hir branch August 31, 2026 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete the OverPy semantic HIR surface

2 participants