Skip to content

Support more attributes in pyk, skip polymorphic rule handling in frontend - #4916

Merged
ehildenb merged 8 commits into
developfrom
att-handling-cleanup
May 8, 2026
Merged

Support more attributes in pyk, skip polymorphic rule handling in frontend#4916
ehildenb merged 8 commits into
developfrom
att-handling-cleanup

Conversation

@ehildenb

@ehildenb ehildenb commented Apr 27, 2026

Copy link
Copy Markdown
Member

pyk's simplified_module() was diverging from Java's ModuleToKORE.java in two distinct ways, both of which caused Kore output mismatches when cross-validating against the Java backend. This addresses that.

Changes:

  • kast/att: add frontend-only attributes HYBRID, PUBLIC, STREAM, and UNUSED; strip them in DiscardSymbolAtts during simplified_module(), matching Java's shouldEmit() filter
  • konvert/_module_to_kore: fix impurity propagation for polymorphic functions — Java's ComputeTransitiveFunctionDependencies looks up rules by post-sort-injection KLabel (e.g. ite{K}), which never matches the parametric attributesFor() key (ite{SortSort}), so polymorphic functions are silently skipped. An extra pass DiscardPolymorphicSentences is added in pyk to match this behavior. The intention is that eventually we should probably not discard polymorphic sentences, so it's factored into its own pass with a comment.
  • Add integration test cases frontend-only.k and coverage.k to the module-to-kore test-data suite covering all four frontend-only attributes and the polymorphic rule skipping behavior
  • Improves an error message in kompile.py.
  • Unskips several now-passing regression-new tests in pyk.

ehildenb and others added 4 commits April 27, 2026 22:52
… frontend-only attributes from Kore emission

Add `frontend_only: bool` flag to `AttKey` mirroring Java's `KeyRange.FrontendOnly`.
Add `Atts.HYBRID`, `Atts.PUBLIC`, `Atts.STREAM`, `Atts.UNUSED` with `frontend_only=True`
and proper types matching `KeyParameter.Optional`/`KeyParameter.Forbidden` in `Att.scala`.
Include these in `DiscardSymbolAtts` in `simplified_module()` so they are stripped before
Kore emission, matching Java's `ModuleToKORE.java` `shouldEmit()` filter.

Add integration test cases `unused.k` and `frontend-only.k` (covering all four attributes)
to the `module-to-kore` test-data suite.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The frontend_only field on AttKey was purely decorative — DiscardSymbolAtts is the
actual suppression mechanism and its explicit list is the source of truth. Remove the
field to keep AttKey simple.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ctions

Java's ComputeTransitiveFunctionDependencies groups function rules by their
post-sort-injection KLabel (e.g. ite{K}), which doesn't match the parametric
production entry in attributesFor() (ite{SortSort}). The mismatch causes Java
to silently skip dependency-graph edges for polymorphic function rules, so
polymorphic functions are never marked impure transitively.

Mirror this behavior in AddImpureAtts._callers() by excluding productions with
non-empty klabel.params from the set of labels whose rules are processed.

Fixes a false-positive impure{} annotation on ite in coverage-instrumented
compilations (81/82 regression-new dirs now agree with Java, up from 78/82).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…polymorphic rule skipping

Add a warning log in AddImpureAtts._callers() when a rule for a polymorphic
function (klabel.params non-empty) is encountered and skipped. This makes the
silent Java-parity behavior visible at run time.

Add coverage.k to the module-to-kore integration test suite: a definition
compiled with --coverage that uses #if...#fi (desugaring to the polymorphic
ite function). With coverage instrumentation, ite gets rules calling #logToFile
(impure), but must NOT be marked impure because Java's dependency analysis also
skips polymorphic function rules. The test directly exercises the fix from the
previous commit and verifies Python/Java structural-axiom agreement.

EXTRA_KOMPILE_ARGS in the test fixture maps filenames to non-default kompile
options, keeping all test data files using auto-derived module names.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@rv-jenkins
rv-jenkins changed the base branch from master to develop April 27, 2026 22:56
ehildenb and others added 4 commits April 29, 2026 19:47
…compat pass

Add DiscardPolymorphicSentences(SingleModulePass) that removes KRule sentences
whose LHS applies a polymorphic function label (klabel.params non-empty and
FUNCTION attribute present), mirroring the silent Java behaviour where
ComputeTransitiveFunctionDependencies finds no rules for such labels due to the
post-sort-injection KLabel / parametric attributesFor() key mismatch.

Inserting this pass before AddImpureAtts lets that pass revert to simple
function_labels logic with no poly_labels special-case or warning log. All Java
compatibility concern is now in one named, documented place.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ehildenb
ehildenb marked this pull request as ready for review May 8, 2026 00:22
@ehildenb
ehildenb requested a review from tothtamas28 May 8, 2026 00:22
@ehildenb
ehildenb merged commit 78ba5dc into develop May 8, 2026
20 checks passed
@ehildenb
ehildenb deleted the att-handling-cleanup branch May 8, 2026 17:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants