Skip to content

Unused argument is evaluated natively but skipped by bend file.bend #775

Closed

Description

@danielotaviano

What you did

/usr/bin/time -p bend pick.bend and bend pick.bend -o pick && /usr/bin/time -p ./pick

What happened

Both return 1n, but bend pick.bend skips the expensive unused argument while the native executable evaluates it. With boom(32n), the native run took about 53 times longer (compilation excluded).


$ /usr/bin/time -p bend pick.bend
1n
real 0.23
user 0.23
sys 0.08

$ bend pick.bend -o pick

$ /usr/bin/time -p ./pick
1n
real 12.17
user 11.40
sys 0.04

All commands exited successfully. These are timings from one local run. The difference is in evaluation and execution time, not the returned value. For this pure main, bend pick.bend uses the checker normalizer.

Is this difference expected?

The file

import Base

def pick(-A: Type, c: Bool, a: A, b: A) -> A:
  match c:
    case True{}:
      a
    case False{}:
      b

def boom(+n: Nat) -> Nat:
  match n:
    case 0n:
      0n
    case 1n+p:
      Nat.add(boom(p), boom(p))

def main() -> Nat:
  pick(Nat, True{}, 1n, boom(32n))

bend --version

bend 2.0.4

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 17.0.0 (clang-1700.6.4.2)

Activity

  1. added
    bug
    on Sep 17, 2026
  2. VictorTaelin commented on Sep 18, 2026

    @VictorTaelin
    Contributor

    Doc part fixed in 2.0.6: the guide's command list said bend file.bend runs main "on the JS backend"; it now says an IO main runs compiled and a value main is normalized by the checker. Whether pure mains should also run strictly (through the JS lane) is still being decided; the values never differ, only the cost.

    Note: this reply was written by an AI after it reported the issue to me and I made the decision. If anything here is wrong, reply and I will review it myself.

  3. added a commit that references this issue on Sep 18, 2026
    c00b919
  4. added a commit that references this issue on Sep 27, 2026
    8c024fb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions