Skip to content

Improve Symbol information in Block IR#412

Open
ChingLongTin wants to merge 311 commits intohkust-taco:hkmc2from
ChingLongTin:patch
Open

Improve Symbol information in Block IR#412
ChingLongTin wants to merge 311 commits intohkust-taco:hkmc2from
ChingLongTin:patch

Conversation

@ChingLongTin
Copy link
Contributor

@ChingLongTin ChingLongTin commented Mar 12, 2026

This adds more types of Symbols to Block IR, and addresses both comments in #355.
#355 (comment): we now require :ftc to be enabled for functions with multiple parameter lists
#355 (comment): we collect all class definitions during compilation into defnMap so that we can retrieve the definition for desugared classes generated from :ftc

In the future, we will need change StagedSymbols.mls to show that we have staged the Symbols correctly.
Instead of relying on the printout from showBlock, we probably will need to print the global map of created symbols, since showBlock will be used for pretty-printing code for the next stage and will not show a difference between the different types of symbols.

@ChingLongTin ChingLongTin changed the title Patch to #355 Improve Symbol information in Block iR Mar 12, 2026
@ChingLongTin ChingLongTin changed the title Improve Symbol information in Block iR Improve Symbol information in Block IR Mar 12, 2026
@LPTK
Copy link
Contributor

LPTK commented Mar 12, 2026

Thanks. Please mark the PR as ready when it's ready for a review.

@ChingLongTin ChingLongTin marked this pull request as ready for review March 13, 2026 04:21
@LPTK LPTK requested review from NeilKleistGao and Copilot March 13, 2026 04:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR enhances Block IR symbol fidelity (introducing distinct symbol variants like VirtualClassSymbol, ClassSymbol with richer metadata, and ModuleSymbol) and updates the staging/instrumentation pipeline to support these richer symbols, including stricter handling of multi-parameter-list functions via :ftc.

Changes:

  • Extend Block IR symbol model and adjust pretty-printing to rely on symbol toString().
  • Update Scala instrumentation to emit richer symbol objects and to pre-collect class definitions (defnMap) for later lookup.
  • Refresh/add staging golden tests and extend Shape primitive-type handling (adds TypedArray).

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
hkmc2/shared/src/test/mlscript/block-staging/StageSymbols.mls Adds coverage for richer symbols and :ftc error behavior in staged output.
hkmc2/shared/src/test/mlscript/block-staging/Functions.mls Updates golden outputs for new symbol formatting and :ftc behavior.
hkmc2/shared/src/test/mlscript-compile/Shape.mls Extends primitive-type checks to include TypedArray.
hkmc2/shared/src/test/mlscript-compile/Block.mls Updates Block IR model for richer symbol types and simplifies symbol printing.
hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala Switches instrumentation entrypoint to applyBlockFinal to build defnMap before staging.
hkmc2/shared/src/main/scala/hkmc2/codegen/Instrumentation.scala Implements richer symbol emission, defnMap collection, and :ftc enforcement for multi-parameter lists.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ChingLongTin and others added 5 commits March 13, 2026 13:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
classes staged into VirtualSymbol and literals in Block IR are independent, and Literals do not have TypedArray
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.

5 participants