Skip to content

Support "match only" mode in pattern compilation#421

Open
chengluyu wants to merge 16 commits intohkust-taco:hkmc2from
chengluyu:ups/match-only
Open

Support "match only" mode in pattern compilation#421
chengluyu wants to merge 16 commits intohkust-taco:hkmc2from
chengluyu:ups/match-only

Conversation

@chengluyu
Copy link
Member

No description provided.

Copy link
Contributor

@LPTK LPTK left a comment

Choose a reason for hiding this comment

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

Ok, let's get this merged, thanks. However there is a pre-existing problem with the difference between compiled and interpreted patterns (see #422).

// When the instantiated pattern is transform-free and thus preserves the
// original scrutinee as its output, `MatchOnly` is used and the caller can
// obtain the scrutinee directly.
val canReuseScrutineeOutput = preservesScrutineeOutput(synonym, context)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be

Suggested change
val canReuseScrutineeOutput = preservesScrutineeOutput(synonym, context)
val canReuseScrutineeAsOutput = preservesScrutineeAsOutput(synonym, context)

?

Comment on lines 98 to 100
// Comments: I think the output from the compiled pattern is semantically
// correct, but people might expect the output from the translated pattern.
// The problem is that we can't synthesize a record with the class tags.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment outdated?

//│ };
//│ end

:sir
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is too much output to commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please clean up this file: only keep one or two small, representative uses of :sir.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please clean up this file: only keep one or two small, representative uses of :sir.

LPTK added 2 commits March 21, 2026 10:09
# Conflicts:
#	hkmc2/shared/src/test/mlscript/ups/MatchResult.mls
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.

2 participants