Add basic intraprocedural flow-sensitive analysis for optimization#481
Add basic intraprocedural flow-sensitive analysis for optimization#481LPTK wants to merge 78 commits into
Conversation
Agent-Logs-Url: https://github.com/LPTK/mlscript/sessions/63b4fea7-7c56-467f-81c1-6c8561e8ea62 Co-authored-by: LPTK <2545083+LPTK@users.noreply.github.com>
… prevent incorrect constant folding in nested while loops Agent-Logs-Url: https://github.com/LPTK/mlscript/sessions/63b4fea7-7c56-467f-81c1-6c8561e8ea62 Co-authored-by: LPTK <2545083+LPTK@users.noreply.github.com>
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/MLsCompiler.scala # hkmc2/shared/src/test/mlscript/codegen/Inliner.mls # hkmc2/shared/src/test/mlscript/deforest/simple.mls # hkmc2/shared/src/test/mlscript/handlers/Debugging.mls # hkmc2/shared/src/test/mlscript/handlers/SavedVars.mls # hkmc2/shared/src/test/mlscript/wasm/Basics.mls # hkmc2/shared/src/test/mlscript/wasm/MainFunctions.mls # hkmc2/shared/src/test/mlscript/wasm/ScopedLocals.mls # hkmc2/shared/src/test/mlscript/wasm/SingletonUnit.mls # hkmc2/shared/src/test/mlscript/wasm/Strings.mls # hkmc2DiffTests/src/test/scala/hkmc2/JSBackendDiffMaker.scala
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/MLsCompiler.scala # hkmc2/shared/src/main/scala/hkmc2/codegen/Block.scala # hkmc2/shared/src/test/mlscript/codegen/FirstClassFunctionTransform.mls # hkmc2/shared/src/test/mlscript/dead-param-elim/class-in-fun.mls # hkmc2/shared/src/test/mlscript/handlers/EffectsHygiene.mls # hkmc2/shared/src/test/mlscript/tailrec/TailRecOpt.mls # hkmc2DiffTests/src/test/scala/hkmc2/JSBackendDiffMaker.scala
# Conflicts: # hkmc2/shared/src/test/mlscript-compile/Runtime.mjs # hkmc2/shared/src/test/mlscript/basics/Assert.mls # hkmc2/shared/src/test/mlscript/codegen/SanityChecks.mls
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/MLsCompiler.scala # hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTransformer.scala # hkmc2/shared/src/test/mlscript/wasm/SingletonUnit.mls
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/codegen/Block.scala # hkmc2/shared/src/main/scala/hkmc2/codegen/BlockSimplifier.scala # hkmc2/shared/src/main/scala/hkmc2/package.scala # hkmc2/shared/src/test/mlscript-compile/Predef.mjs # hkmc2/shared/src/test/mlscript-compile/Runtime.mjs # hkmc2/shared/src/test/mlscript/basics/Indentation.mls # hkmc2/shared/src/test/mlscript/basics/LazySpreads.mls # hkmc2/shared/src/test/mlscript/basics/ShortcircuitingOps.mls # hkmc2/shared/src/test/mlscript/block-staging/Functions.mls # hkmc2/shared/src/test/mlscript/codegen/NestedScoped.mls # hkmc2/shared/src/test/mlscript/codegen/PartialApps.mls # hkmc2/shared/src/test/mlscript/codegen/SanityChecks.mls # hkmc2/shared/src/test/mlscript/codegen/TraceLogIndent.mls # hkmc2/shared/src/test/mlscript/deforest/simple.mls # hkmc2/shared/src/test/mlscript/invalml/InvalMLCodeGen.mls # hkmc2/shared/src/test/mlscript/invalml/InvalMLGetters.mls
# Conflicts: # hkmc2/shared/src/test/mlscript/wasm/Basics.mls
|
I still have to clean up the OptScratch files, but other than that, the PR is ready to review (not commit by commit, obviously). |
There was a problem hiding this comment.
Pull request overview
Adds a basic intraprocedural, flow-sensitive optimization pass (variable/constant propagation and related simplifications) and wires it into the compiler and diff-test harness, with extensive golden-output updates and new optimization-focused test cases.
Changes:
- Integrate optimization pipeline updates (BlockSimplifier + DeadParamElim) with optional debugging/disable switches in diff tests and compiler entrypoints.
- Add new config toggles (e.g.,
deadBranchRemoval) and sanity-check behavior (runtime trapping onUnreachablewhen enabled). - Update/add many
.mlsgolden tests to reflect optimized IR/JS output.
Reviewed changes
Copilot reviewed 125 out of 126 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| hkmc2DiffTests/src/test/scala/hkmc2/Watcher.scala | Always prints watcher exception stack traces for easier debugging. |
| hkmc2DiffTests/src/test/scala/hkmc2/MLsDiffMaker.scala | Adds :dopt/:noOpt commands; tweaks sanity-check config wiring. |
| hkmc2DiffTests/src/test/scala/hkmc2/JSBackendDiffMaker.scala | Adds optimization tracing/logging hooks and :noOpt gating. |
| hkmc2DiffTests/src/test/scala/hkmc2/DiffTestRunner.scala | Refactors timeout behavior to shared base; tweaks local time limit. |
| hkmc2/shared/src/test/mlscript/wasm/VirtualMethods.mls | Golden output update for optimized Wasm codegen. |
| hkmc2/shared/src/test/mlscript/wasm/Strings.mls | Golden output update for optimized Wasm codegen. |
| hkmc2/shared/src/test/mlscript/wasm/SingletonUnit.mls | Golden output update for optimized Wasm codegen. |
| hkmc2/shared/src/test/mlscript/wasm/ScopedLocals.mls | Golden output update for optimized Wasm codegen. |
| hkmc2/shared/src/test/mlscript/wasm/ReplImports.mls | Golden output update for optimized Wasm codegen. |
| hkmc2/shared/src/test/mlscript/wasm/Matching.mls | Golden output update for optimized Wasm codegen. |
| hkmc2/shared/src/test/mlscript/wasm/MainFunctions.mls | Golden output update for optimized Wasm codegen. |
| hkmc2/shared/src/test/mlscript/wasm/ClassInheritance.mls | Golden output update (incl. diagnostic line numbers). |
| hkmc2/shared/src/test/mlscript/wasm/Basics.mls | Golden output update (incl. diagnostic expectations). |
| hkmc2/shared/src/test/mlscript/ups/syntax/MixedParameters.mls | Updates expected runtime/compile behavior outputs. |
| hkmc2/shared/src/test/mlscript/ups/SimpleTransform.mls | Adds note + spacing; keeps test intent. |
| hkmc2/shared/src/test/mlscript/ups/RecursiveTransformations.mls | Updates expected outputs and diagnostic locations. |
| hkmc2/shared/src/test/mlscript/ups/examples/PrecedenceClimbStackParse.mls | Updates expected outputs and diagnostic locations. |
| hkmc2/shared/src/test/mlscript/ups/examples/Extraction.mls | Adds :noOpt to keep a known IR rebinding failure visible. |
| hkmc2/shared/src/test/mlscript/ups/examples/BadRecStackParse.mls | Golden output update. |
| hkmc2/shared/src/test/mlscript/ucs/patterns/RestTuple.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/ucs/patterns/Parameters.mls | Golden output update for pattern parameter handling. |
| hkmc2/shared/src/test/mlscript/ucs/normalization/ExcessiveDeduplication.mls | Golden JS update for dedup/branch simplification changes. |
| hkmc2/shared/src/test/mlscript/ucs/normalization/DeduplicationWhile.mls | Golden JS update for while/dedup simplification changes. |
| hkmc2/shared/src/test/mlscript/ucs/normalization/Deduplication.mls | Golden JS update for dedup/constant propagation. |
| hkmc2/shared/src/test/mlscript/ucs/general/LogicalConnectives.mls | Golden output update + diagnostic location tweaks. |
| hkmc2/shared/src/test/mlscript/tailrec/TailRecOpt.mls | Golden JS update for renamed params / simplification. |
| hkmc2/shared/src/test/mlscript/syntax/BasicIfs.mls | Updates expected output values. |
| hkmc2/shared/src/test/mlscript/std/FingerTreeListTest.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/parser/PrefixOps.mls | Golden JS/output update for folded prefix ops. |
| hkmc2/shared/src/test/mlscript/opt/ValPropag.mls | New optimization test for val/let propagation behavior. |
| hkmc2/shared/src/test/mlscript/opt/OptScratch3.mls | New scratch/regression tests for optimizer behavior. |
| hkmc2/shared/src/test/mlscript/opt/OptScratch2.mls | New scratch/regression tests for optimizer behavior. |
| hkmc2/shared/src/test/mlscript/opt/OptScratch.mls | New scratch/regression tests for optimizer behavior. |
| hkmc2/shared/src/test/mlscript/opt/MatchSimplification.mls | New test for match/if simplification under optimization. |
| hkmc2/shared/src/test/mlscript/opt/LoopOpt.mls | New test for loop-related optimization behavior. |
| hkmc2/shared/src/test/mlscript/opt/IllFormedAccesses.mls | New test documenting optimizer effects on UB (uninitialized access). |
| hkmc2/shared/src/test/mlscript/opt/DeadVarRemoval.mls | Golden IR update for dead var removal behavior. |
| hkmc2/shared/src/test/mlscript/opt/DeadSelRemoval.mls | Golden IR update for dead selection elimination behavior. |
| hkmc2/shared/src/test/mlscript/opt/DeadObjRemoval.mls | Golden JS/IR update for dead object elimination behavior. |
| hkmc2/shared/src/test/mlscript/opt/DeadBranchRemoval.mls | New tests for dead-branch removal feature flag. |
| hkmc2/shared/src/test/mlscript/opt/DeadAssignmentRemoval.mls | New tests for dead assignment elimination behavior. |
| hkmc2/shared/src/test/mlscript/opt/ConstantFolding.mls | New tests covering constant folding and iteration behavior. |
| hkmc2/shared/src/test/mlscript/opt/BasicVarPropag.mls | New comprehensive tests for variable propagation + folding. |
| hkmc2/shared/src/test/mlscript/opt/AbortivePrefix.mls | Golden outputs updated for abortive-prefix simplification. |
| hkmc2/shared/src/test/mlscript/invalml/InvalMLGetters.mls | Golden output/diagnostic location updates. |
| hkmc2/shared/src/test/mlscript/invalml/InvalMLCodeGen.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/handlers/SetInHandlers.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/handlers/SavedVars.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/handlers/RecursiveHandlers.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/handlers/NoStackSafety.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/handlers/Fallthrough.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/handlers/EffectsHygiene.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/handlers/Debugging.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/deforest/simple.mls | Golden output update for deforest-related naming changes. |
| hkmc2/shared/src/test/mlscript/deforest/relaxedPrograms.mls | Golden output update (includes expected JS syntax error caret). |
| hkmc2/shared/src/test/mlscript/deforest/nestedMatch.mls | Golden output update for deforest-related naming changes. |
| hkmc2/shared/src/test/mlscript/dead-param-elim/ups.mls | Golden output update for dead-param-elim tracing. |
| hkmc2/shared/src/test/mlscript/dead-param-elim/lambda.mls | Adds optimized IR section to dead-param-elim test. |
| hkmc2/shared/src/test/mlscript/dead-param-elim/clash.mls | Golden output update for eliminable param set changes. |
| hkmc2/shared/src/test/mlscript/ctx/Summon.mls | Diagnostic location updates. |
| hkmc2/shared/src/test/mlscript/codegen/WhileDefaults.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/While.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/TraceLogIndent.mls | Golden REPL trace output update reflecting simplification. |
| hkmc2/shared/src/test/mlscript/codegen/Throw.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/SwitchSpecialization.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/SetIn.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/ScopedBlocksAndHandlers.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/ScopedBlocks.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/SanityChecks.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/Repl.mls | Golden REPL output update reflecting constant folding. |
| hkmc2/shared/src/test/mlscript/codegen/RandomStuff.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/Quasiquotes.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/PartialApps.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/ParamClasses.mls | Golden JS/diagnostic location updates. |
| hkmc2/shared/src/test/mlscript/codegen/NestedScoped.mls | Golden IR/JS updates reflecting optimization effects. |
| hkmc2/shared/src/test/mlscript/codegen/NestedLoops.mls | New test for nested-loop optimized IR behavior. |
| hkmc2/shared/src/test/mlscript/codegen/Formatting.mls | Golden JS formatting updates due to propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/Functions.mls | Golden REPL output update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/Misc.mls | Golden JS update reflecting constant folding. |
| hkmc2/shared/src/test/mlscript/codegen/MergeMatchArms.mls | Golden JS/IR updates reflecting match/branch simplification. |
| hkmc2/shared/src/test/mlscript/codegen/Lambdas.mls | Golden JS update reflecting lambda simplification. |
| hkmc2/shared/src/test/mlscript/codegen/Inliner.mls | Golden IR update + enables deadBranchRemoval for inliner tests. |
| hkmc2/shared/src/test/mlscript/codegen/Hygiene.mls | Golden output update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/GlobalThis.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/FunInClass.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/ConsoleLog.mls | Golden JS update reflecting constant folding/propagation. |
| hkmc2/shared/src/test/mlscript/codegen/ConfigDirective.mls | Moves dead-param-elim trace output to match new behavior. |
| hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls | Golden JS/IR updates reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/CaseShorthand.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/CaseOfCase.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/BuiltinSymbols.mls | Golden IR update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/codegen/BuiltinOps.mls | Golden JS update reflecting constant folding. |
| hkmc2/shared/src/test/mlscript/block-staging/Functions.mls | Adds :noOpt to preserve known IR rebinding failure visibility. |
| hkmc2/shared/src/test/mlscript/basics/StrTest.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/basics/ShortcircuitingOps.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/basics/PureTermStatements.mls | Golden JS update reflecting DCE/sequence simplification. |
| hkmc2/shared/src/test/mlscript/basics/MultilineExpressions.mls | Golden JS/diagnostic location updates reflecting folding. |
| hkmc2/shared/src/test/mlscript/basics/MemberProjections.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/basics/LazySpreads.mls | Golden JS/diagnostic location updates reflecting propagation. |
| hkmc2/shared/src/test/mlscript/basics/Indentation.mls | Adds optimized IR section for an indentation-related case. |
| hkmc2/shared/src/test/mlscript/basics/FunnyRecordKeys.mls | Golden JS update reflecting propagation/simplification. |
| hkmc2/shared/src/test/mlscript/basics/DynamicSelection.mls | Golden diagnostic output updates. |
| hkmc2/shared/src/test/mlscript/basics/Drop.mls | Golden JS update reflecting constant folding. |
| hkmc2/shared/src/test/mlscript/basics/Assert.mls | Golden JS/diagnostic location updates reflecting folding. |
| hkmc2/shared/src/test/mlscript/backlog/Lifter.mls | Golden runtime output text updates reflecting renaming. |
| hkmc2/shared/src/test/mlscript/backlog/ForLLM.mls | Adds additional parser/backlog repro cases and expected errors. |
| hkmc2/shared/src/test/mlscript-compile/Predef.mls | Adds hide/maybe helpers to stabilize tests against optimization. |
| hkmc2/shared/src/test/mlscript-compile/Predef.mjs | Updates generated Predef JS to include new helpers and simplifications. |
| hkmc2/shared/src/main/scala/hkmc2/utils/utils.scala | Adds filterConserve to preserve list identity when unchanged. |
| hkmc2/shared/src/main/scala/hkmc2/semantics/Symbol.scala | Adds showDbg; introduces LocalVarSymbol and refines symbol hierarchy. |
| hkmc2/shared/src/main/scala/hkmc2/package.scala | Adds abbreviate helper; minor naming tweak in extension. |
| hkmc2/shared/src/main/scala/hkmc2/MLsCompiler.scala | Integrates optimizer pipeline and adds optimization trace logger. |
| hkmc2/shared/src/main/scala/hkmc2/Config.scala | Adds deadBranchRemoval; extends sanity checks; parses new config field. |
| hkmc2/shared/src/main/scala/hkmc2/codegen/Printer.scala | Minor formatting tweak. |
| hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala | Adds resultQual; emits runtime traps for Unreachable under sanity checks. |
| hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTraverser.scala | Refactors class-like def traversal into helper. |
| hkmc2/shared/src/main/scala/hkmc2/codegen/BlockTransformer.scala | Refactors class-like def transformation into helper. |
| hkmc2/shared/src/main/scala/hkmc2/codegen/Block.scala | Adds debug renderers; fixes Scoped free-vars; match simplification tweak. |
| hkmc2/jvm/src/test/scala/hkmc2/TimeOutTests.scala | New shared timeout base for ScalaTest suites. |
| hkmc2/jvm/src/test/scala/hkmc2/CompileTestRunnerBase.scala | Switches to shared timeout base; adds timeLimit. |
| .github/skills/hkmc2-difftests/references/commands-and-policies.md | Documents new/related debugging commands. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var testName: Str = "‹unknown›" | ||
| override def withFixture(test: NoArgTest) = | ||
| testName = test.name | ||
| super.withFixture(test) | ||
| override val defaultTestSignaler: Signaler = new Signaler: | ||
| @annotation.nowarn("msg=method stop in class Thread is deprecated") def apply(testThread: Thread): Unit = | ||
| println(s"[${Thread.currentThread().getName}] running ${testThread.getName} has run out of time!") | ||
| println(s"!! Test $testName at $testThread has run out out time !! stopping..." + | ||
| "\n\tNote: you can increase this limit by changing DiffTests.TimeLimit") |
|
I can have a look in the coming day or two. |
|
I've just done a high-level review of the new |
# Conflicts: # hkmc2/shared/src/main/scala/hkmc2/MLsCompiler.scala # hkmc2/shared/src/test/mlscript/deforest/nestedMatch.mls
AnsonYeung
left a comment
There was a problem hiding this comment.
I think the loop logic is missing a merge for the loop start.
| private var changed = true | ||
| val deadBranchRemoval = config.deadBranchRemoval | ||
|
|
||
| val MaxIterations = 10 |
There was a problem hiding this comment.
Why is this variable name capitalized
| // * Replace with `undefined` those references to local variables that are never assigned | ||
| case Value.Ref(loc, N) if localVars.contains(loc) && !definedVars.contains(loc) => | ||
| registerChange | ||
| registerChange("TODO: description") |
There was a problem hiding this comment.
Seems there are many TODOs in registerChange
| def merge(that: AssignInfo): AssignInfo = | ||
| if this is that then this | ||
| else that match | ||
| case Unknown => that | ||
| case Uninitialized => this | ||
| // case Merge(l, r) => Merge(merge(this, l), r) | ||
| case _: Assigned | _: Merge => Merge(this, that) | ||
|
|
There was a problem hiding this comment.
If this is Unknown | Uninitialized then a Merge will be created
| assignedResults = oldAssignedResults | ||
| res | ||
|
|
||
| val atLabelBegin: MutMap[LabelSymbol, AssignedResults] = MutMap.empty.withDefaultValue(emptyAssignedResults) |
There was a problem hiding this comment.
It seems to me that atLabelBegin is effectively unused, the only usage only put the result back into the same map
| @inline def regChange = | ||
| registerChange(s"Arm ${pat.showDbg} is unreachable because") | ||
| false | ||
| pat match | ||
| case Case.Lit(lit) => | ||
| shapes.contains(lit) && { shapes -= lit; true } || regChange | ||
| case Case.Cls(sym, _) => | ||
|
|
||
| // FIXME: take inheritance into account | ||
| // FIXME: take lit <: virual-cls into account (such as true <: Bool) | ||
|
|
||
| shapes.contains(sym) && { shapes -= sym; true } || regChange |
There was a problem hiding this comment.
| @inline def regChange = | |
| registerChange(s"Arm ${pat.showDbg} is unreachable because") | |
| false | |
| pat match | |
| case Case.Lit(lit) => | |
| shapes.contains(lit) && { shapes -= lit; true } || regChange | |
| case Case.Cls(sym, _) => | |
| // FIXME: take inheritance into account | |
| // FIXME: take lit <: virual-cls into account (such as true <: Bool) | |
| shapes.contains(sym) && { shapes -= sym; true } || regChange | |
| @inline def regChange(reason: Str) = | |
| registerChange(s"Arm ${pat.showDbg} is unreachable. Reason: ${reason}") | |
| false | |
| pat match | |
| case Case.Lit(lit) => | |
| shapes.contains(lit) && { shapes -= lit; true } || regChange("Impossible literal") | |
| case Case.Cls(sym, _) => | |
| // FIXME: take inheritance into account | |
| // FIXME: take lit <: virual-cls into account (such as true <: Bool) | |
| shapes.contains(sym) && { shapes -= sym; true } || regChange("Impossible instanceof") |
|
|
||
| fun f(x) = if x is str as AtPrec as prec then [str, prec] | ||
| f("+") | ||
| //│ = ["+", 2] |
There was a problem hiding this comment.
This seems like some weird diff
| // * Notice: wrong assoc. | ||
| parse("a" :: "+" :: "(" :: "b" :: "+" :: "x" :: "+" :: "y" :: ")" :: Nil) | ||
| //│ = {Success: Op(Id("a"), "+", Op(Id("b"), "+", Op(Id("x"), "+", Id("y"))))} |
| //│ = ["+", 5] | ||
| f("*") |
| f("+") | ||
| //│ = ["+", 5] |
| arr is MultiSet(1, _) | ||
| //│ = true | ||
| arr is MultiSet(0, _) | ||
| //│ = false | ||
| arr is MultiSet(3, _) | ||
| //│ = true | ||
| arr is MultiSet(3, MultiSet(1, MultiSet(2, Nil))) | ||
| //│ = true | ||
| arr is MultiSet(3, MultiSet(0, _)) | ||
| //│ = false |
There was a problem hiding this comment.
seems like ups use this broken style of test a lot which breaks on this pr a lot
For now, this is mostly for propagating transitive variable assignments and folding constants. We can later fully leverage the results to simplify pattern matching expressions, remove dead assignments, etc.