Skip to content

Inliner and refresher fixes#506

Merged
LPTK merged 28 commits into
hkust-taco:hkmc2from
LPTK:inliner-lifter-refresher-fixes
Jun 5, 2026
Merged

Inliner and refresher fixes#506
LPTK merged 28 commits into
hkust-taco:hkmc2from
LPTK:inliner-lifter-refresher-fixes

Conversation

@LPTK

@LPTK LPTK commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

The inlining threshold was not properly picked up in diff-tests (it defaulted to 1). Fixing this exposed a bunch of issues, which I mostly fixed throguh Copilot/Codex.

LPTK and others added 28 commits June 2, 2026 17:40
This commit seems to uncover a lot of bugs probably related to inlining

# Conflicts:
#	hkmc2/shared/src/test/mlscript/deforest/fusibility.mls
#	hkmc2/shared/src/test/mlscript/opt/InlineModuleMethods.mls
Agent-Logs-Url: https://github.com/LPTK/mlscript/sessions/b07c80eb-8e80-4382-8e61-53c072d6e23f

Co-authored-by: LPTK <2545083+LPTK@users.noreply.github.com>

# Conflicts:
#	hkmc2/shared/src/test/mlscript/codegen/ClassInFun.mls
#	hkmc2/shared/src/test/mlscript/lifter/DefnsInClass.mls
…e-mapped ctor symbols

When the inliner copies a function body containing a data class definition,
the SymbolRefresher creates fresh symbols. Two issues were fixed:

1. The refreshed ClassSymbol was missing its source-level `defn`, causing
   JSBuilder's `shouldBeLifted` to return false and the static block to
   assign `this` directly to the variable (instead of `.class` property),
   overwriting the wrapper function.

2. The ClassCtorSymbol could already be mapped to a TermSymbol (by the
   FunDefn case for the wrapper function). The original assertion
   `assert(!mapping.isDefinedAt(cs))` would crash. Now we create a fresh
   ClassCtorSymbol without overwriting the mapping, preserving correct
   MemberRef disambiguation for the wrapper function.

Co-authored-by: LPTK <2545083+LPTK@users.noreply.github.com>
ClassInFun.mls and FunInClass.mls: assertion crashes now produce correct results.
LazyFingerTreeTest.mls: pre-existing compile test failure reflected in runtime.

Co-authored-by: LPTK <2545083+LPTK@users.noreply.github.com>

# Conflicts:
#	hkmc2/shared/src/test/mlscript/codegen/ClassInFun.mls
#	hkmc2/shared/src/test/mlscript/codegen/FunInClass.mls
…for number literal property access

Co-authored-by: LPTK <2545083+LPTK@users.noreply.github.com>

# Conflicts:
#	hkmc2/shared/src/main/scala/hkmc2/codegen/BlockSimplifier.scala
#	hkmc2/shared/src/test/mlscript/HkScratch.mls
#	hkmc2/shared/src/test/mlscript/ucs/patterns/SimpleTuple.mls
@LPTK LPTK marked this pull request as ready for review June 5, 2026 03:25
@LPTK LPTK changed the title Inliner, lifter, and refresher fixes Inliner and refresher fixes Jun 5, 2026
@LPTK LPTK merged commit 256961a into hkust-taco:hkmc2 Jun 5, 2026
1 check passed
@LPTK LPTK deleted the inliner-lifter-refresher-fixes branch June 5, 2026 03:32
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.

3 participants