Skip to content

feat(flowc): generic skip, bitwise ~ and &, more integer types - #436

Merged
godofecht merged 1 commit into
mainfrom
work
Aug 11, 2026
Merged

godofecht merged 1 commit into
mainfrom
work

Conversation

@godofecht

Copy link
Copy Markdown
Contributor

Summary

  • compiler/src/token.flow: add TOK_TILDE (36) for bitwise not operator.
  • compiler/src/lexer.flow: tokenize ~ as TOK_TILDE.
  • compiler/src/parser.flow: parse and skip generic type parameters (<T, U: Trait>) after function names. Mark generic functions with ival=1 on the AST_FN node. Add TOK_AMP as a binary operator (bitwise and) with precedence 3. Add TOK_TILDE as a unary operator.
  • compiler/src/cgen.flow: emit ~ for TOK_TILDE unary, & for TOK_AMP binary. Add type mappings for i8, i16, u16, u32, u64, bool. Skip generic functions in the function emission pass.
  • compiler/src/typecheck.flow: skip generic functions in both flowc_tc_collect_globals and flowc_tc_check_fns.
  • compiler/bootstrap/flowc_stage_a.c: regenerated from updated source.

Context

lib/stdlib/memory.flow uses generic functions (sizeof<T>), bitwise operators (&, ~), and integer types (i8, i64) that the self-hosted compiler didn't handle. With these changes, memory.flow compiles to valid C with zero errors.

Test plan

  • ./flow run compiler/src/main.flow passes (flowc: PASS)
  • Three consecutive generation fixed-points pass (byte-identical)
  • lib/stdlib/memory.flow compiles to valid C with zero clang errors

This pull request includes code written with the assistance of AI.
The code has not yet been reviewed by a human.

Generated with Devin

compiler/src/token.flow: add TOK_TILDE (36) for bitwise not operator.
compiler/src/lexer.flow: tokenize ~ as TOK_TILDE.
compiler/src/parser.flow:
  - Parse and skip generic type parameters (<T, U: Trait>) after
    function names. Mark generic functions with ival=1 on the AST_FN
    node so cgen and typecheck can skip them.
  - Add TOK_AMP as a binary operator (bitwise and) with precedence 3.
  - Add TOK_TILDE as a unary operator alongside !, -, &.
compiler/src/cgen.flow:
  - Emit ~ for TOK_TILDE unary, & for TOK_AMP binary.
  - Add type mappings for i8, i16, u16, u32, u64, bool.
  - Skip generic functions (ival == 1) in the function emission pass.
compiler/src/typecheck.flow: skip generic functions in both
  flowc_tc_collect_globals and flowc_tc_check_fns.
compiler/bootstrap/flowc_stage_a.c: regenerated from updated source.

lib/stdlib/memory.flow now compiles to valid C with zero errors.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@cursor

cursor Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@godofecht
godofecht merged commit db36b3c into main Aug 11, 2026
13 checks passed
@godofecht
godofecht deleted the work branch August 11, 2026 23:02
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