Skip to content

Effect Analysis Prototype - #562

Draft
flandia wants to merge 1 commit into
hkust-taco:hkmc2from
flandia:flow-effect
Draft

flandia wants to merge 1 commit into
hkust-taco:hkmc2from
flandia:flow-effect

Conversation

@flandia

@flandia flandia commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

This artifact is endorsed by Anto

@flandia

flandia commented Sep 20, 2026

Copy link
Copy Markdown
Contributor Author

wtf Codex stole my authorship

mono: Bool,
nonAffineTracking: Bool,
accumulatorTracking: Bool,
)(using TraceLogger, Elaborator.State, Raise, SymbolPrinter): FlowConstraintSolver =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👎

@LPTK

LPTK commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Thanks!

As discussed,

  • let's add a flag to Assign nodes to determine their effectfulness. We should make sure not to treat local mutation as a nonlocal side effect;
  • do not use an effectful annotation (just use actual effects instead);
  • make the optimizer not run when the lifter is disabled, so we don't need to care about nested definitions;
  • merge this into the eta expansion pass (later: the megapass).

val fStrat = processResult(f)
val argsStrat = args.map(a => processResult(a.value))
if args.exists(_.spread.isDefined) then
// TODO: preserve callee-effect precision for spread calls without modeling their argument flow.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ychenfo is this the same bug as discussed?

cc.constrain(effect, enclosingEffect)
effect
def constrainConstructorEffect(result: Result): Unit =
val mayRaise = result match

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
val mayRaise = result match
val mayHaveSideEffects = result match

if config.liftDefns.isDefined then
blockPass(Lifter(_).transform)(prog)
else prog
runPass("EffectAnalysis"): prog =>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What si this extra pass for?

@LPTK
LPTK marked this pull request as draft September 21, 2026 10:37
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