Skip to content

Allow comptime expressions as match labels#348

Draft
mbenke wants to merge 2 commits intocomptime-keywordfrom
ct-match-labels
Draft

Allow comptime expressions as match labels#348
mbenke wants to merge 2 commits intocomptime-keywordfrom
ct-match-labels

Conversation

@mbenke
Copy link
Copy Markdown
Collaborator

@mbenke mbenke commented Apr 7, 2026

Allow stuff like

  function classify(x : word) -> word {
    let two : comptime word = 2;
    match x {
      | comptime two + 0             => return 2;
      | comptime toWord(uint256(40)) => return 40;
      | other                        => return other;
    }
  }

The idea is to use it for dispatch instead of chained if statements.

@mbenke mbenke requested a review from rodrigogribeiro April 7, 2026 13:05
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.

1 participant