Skip to content

Bug: comptime pipeline calls to primitive intrinsic methods are rejected #565

Closed

Description

@ehartford

Summary

Pipeline syntax for primitive intrinsic methods works at runtime, but the same expression inside comptime is treated as a free-function call and rejected with comptime can only call comptime functions.

Spec reference

  • docs/with-specification.md §4.2.4 requires integer bit-manipulation methods to be comptime-evaluable when the receiver is constant.
  • Pipeline syntax should be equivalent method-call sugar where a pipeline method is resolved.

Reproduction

//! expect-stdout: ok

const PIPE_ROT: u8 = comptime ((0b10000001 as u8) |> rotate_left(1))

fn main:
    assert(PIPE_ROT == 0b00000011 as u8)
    print("ok")

Expected

The constant evaluates to 3 as u8, matching (0b10000001 as u8).rotate_left(1).

Actual

The checker/evaluator reports:

error: comptime can only call comptime functions

A runtime probe of ((0b10000001 as u8) |> rotate_left(1)) succeeds, so this is specific to the comptime pipeline dispatch path.

Notes

Found while implementing #422. Kept out of that commit because direct method-call comptime evaluation is the Phase 3 requirement, and this is a separate pipeline dispatch-state issue.

Activity

  1. ehartford commented on Jul 4, 2026

    @ehartford
    ContributorAuthor

    Fixed in fde7ed6; build + fixpoint + full suite green. Root cause: top-level comptime initializers are folded by the transform pass before sema types them, so pipeline_method_calls was never populated and eval_pipeline fell to the free-call path. The evaluator now resolves the method-call sugar itself on map miss (via pipeline_method_exists on the evaluated receiver's type) and the pipeline method dispatch gains the missing integer branch, so comptime (x |> rotate_left(1)) evaluates exactly like comptime (x.rotate_left(1)) (§4.2.4 equivalence). The issue's repro is the fixture: test/behavior/behav_comptime_pipeline_intrinsic.w.

  2. added a commit that references this issue on Jul 4, 2026
    fde7ed6
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions