Skip to content

Preserve public prefix when round-tripping Import declarations#990

Merged
jsiek merged 1 commit into
mainfrom
claude/nice-borg-7d2d52
Jun 18, 2026
Merged

Preserve public prefix when round-tripping Import declarations#990
jsiek merged 1 commit into
mainfrom
claude/nice-borg-7d2d52

Conversation

@jsiek

@jsiek jsiek commented Jun 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes category (a) of Remaining lib/ round-trip drift after #987 (4 categories) #988: Import.__str__ now emits a public prefix when visibility == 'public'. Previously, public import IntDefs round-tripped to plain import IntDefs, which both parsers re-interpret as a non-public (private/default) import, dropping the visibility from the canonical AST.
  • Adds test/should-validate/public_import_roundtrip.pf and wires it into PARSER_ROUND_TRIP_FILES so the round-trip harness covers the public import surface form going forward.

Round-trip sweep over lib/ + test/should-validate/ now shows 10 mismatches (was 13); the three files that flipped to clean (lib/Int.pf, lib/IntDefs.pf, lib/UInt.pf) are exactly the ones whose only remaining drift was public import … per #988(a). The remaining 10 are the other three umbrella categories (b)/(c)/(d) and the not X precedence drift tracked separately in #987.

Addresses #988 (category (a)). Refs #931, #987.

Test plan

  • make static (ruff + mypy + mypy --no-site-packages) — clean.
  • python test-deduce.py --equiv — passes, including the new public_import_roundtrip.pf entry in the round-trip list.
  • Manual repro on lib/Int.pf: public import IntDefs now pretty-prints as public import IntDefs under both RD and LALR parsers.
  • python deduce.py --dir test/test-imports test/should-validate/public_import_roundtrip.pfis valid.

Claude session — fallback UUID: 136d134c-5a7e-4ac6-9e7f-b7f1a6cdada5

🤖 Generated with Claude Code

`Import.__str__` hardcoded `'import '`, so `public import IntDefs` round-tripped to `import IntDefs`, which both parsers reinterpret as a non-public import. Emit the `public ` prefix when `visibility == 'public'`, matching the existing surface form.

Adds `public_import_roundtrip.pf` and wires it into `PARSER_ROUND_TRIP_FILES` so the round-trip harness covers the `public import` surface form going forward.

Addresses #988 (category (a)). Refs #931, #987.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jsiek jsiek merged commit afc2250 into main Jun 18, 2026
9 checks passed
@jsiek jsiek deleted the claude/nice-borg-7d2d52 branch June 18, 2026 01:00
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.

1 participant