Skip to content

Fix contification of blocks that are passed as an argument - #1417

Merged
jiribenes merged 2 commits into
mainfrom
jiribenes/fix/contify-value-use
Aug 3, 2026
Merged

Fix contification of blocks that are passed as an argument#1417
jiribenes merged 2 commits into
mainfrom
jiribenes/fix/contify-value-use

Conversation

@jiribenes

@jiribenes jiribenes commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

The non-minimal repro outright crashes, this one "only" miscomputes.

def twice(x: Int) { f: Int => Int }: Int = f(f(x))

def go(): Int = {
  def helper(x: Int): Int = x + 1
  val b = twice(10) {helper}   // value use
  helper(b)                    // tail call
}

twice(10){helper} = 12, helper(12) = 13.

but with --no-optimize, it returns 11 instead of 13:

==> X effekt.JavaScriptTests.examples/pos/contify_block_used_as_value.effekt (js-noopt)  0.337s 
diff assertion failed
=> Obtained
    """|11
       |""".stripMargin
=> Diff (- obtained, + expected)
-11
+13

@jiribenes jiribenes added bug Something isn't working area:js area:cps labels Aug 1, 2026
@jiribenes jiribenes changed the title Fix contification of blocks that are referred to Fix contification of blocks that are passed as an argument Aug 1, 2026
@jiribenes
jiribenes marked this pull request as ready for review August 1, 2026 09:13
@jiribenes
jiribenes requested a review from b-studios August 1, 2026 09:13

@b-studios b-studios left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The new analysis domain for Occurrences does make sense to me, thanks!

@jiribenes
jiribenes merged commit 6094f6b into main Aug 3, 2026
6 of 7 checks passed
@jiribenes
jiribenes deleted the jiribenes/fix/contify-value-use branch August 3, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:cps area:js bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants