-
Notifications
You must be signed in to change notification settings - Fork 35
Unify patterns in UCS and UPS #336
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: hkmc2
Are you sure you want to change the base?
Conversation
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/codegen/Block.scala # hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala # hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/Resolver.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala # hkmc2/shared/src/main/scala/hkmc2/semantics/ups/NaiveCompiler.scala # hkmc2/shared/src/test/mlscript-compile/Runtime.mjs # hkmc2/shared/src/test/mlscript/backlog/ToTriage.mls # hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls # hkmc2/shared/src/test/mlscript/codegen/MergeMatchArms.mls # hkmc2/shared/src/test/mlscript/handlers/NonLocalReturns.mls # hkmc2/shared/src/test/mlscript/handlers/RecursiveHandlers.mls # hkmc2/shared/src/test/mlscript/ucs/general/LogicalConnectives.mls # hkmc2/shared/src/test/mlscript/ups/examples/Record.mls
//│ } | ||
//│ } else if (x3 instanceof None1.class) { return "ok" } else { return Predef.print("oops") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the new approach turns some things that were tail calls into non-tail calls.
I wonder if we could preserve them in general (without duplicating the default branches). Seems difficult.
We probably want to add this to the UCS tracking issue (with a link to this message).
//│ tmp9 = "ok"; | ||
//│ } else { tmp9 = "oops"; } | ||
//│ tmp9 = "oops"; | ||
//│ break split_root$; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to avoid generating this break
when it doesn't do anything?
//│ } | ||
//│ } else { break split_1$3 } | ||
//│ } | ||
//│ tmp4 = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, it would be good to avoid the labels and breaks when the default branch is small (esp. when it's a simple value).
|
||
|
||
// * FIXME should warn, be rejected, or compare both values for equality | ||
:e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:e | |
// * TODO: we might want to accept this and compare the two values for equality | |
:e |
@@ -1431,9 +1431,19 @@ extends Importer with ucs.SplitElaborator: | |||
* variables we found in `p`. */ | |||
def arrow(lhs: Tree, rhs: Tree): Ctxl[Pattern] = | |||
val pattern = go(lhs) | |||
val termCtx = ctx ++ pattern.variables.allocate | |||
val variables = pattern.variables.allocate | |||
// - `contextEntries` will be added to the context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: document why symbols are duplicated here; add to future minor improvements in tracking issue.
No description provided.