Skip to content

Lower all semantically valid integer index expressions without LLVM panics #436

Description

@LunaStev

Summary

LLVM address generation accepts integer literals and a small set of lvalue expressions as array or pointer indices, then panics for other expression forms. Semantically valid indices such as arithmetic expressions, casts, and function results must not reach an unsupported backend panic.

Related issue

Relevant code

  • llvm/src/codegen/address.rs
  • expression lowering and typed expression information
  • semantic index validation

Scope

Use the normal typed integer expression lowering path for index operands, then normalize the resulting integer to the target index width. Keep address calculation and GEP invariants explicit.

Acceptance criteria

  • Literals, variables, arithmetic, grouped expressions, casts, field results, and function-call results work as indices when semantically valid.
  • Signed and unsigned integer widths are normalized deliberately.
  • Non-integer indices are rejected by the frontend with a source diagnostic.
  • No index expression can trigger Index int expr not supported yet or an equivalent panic.
  • Tests cover arrays, pointers, nested indexing, negative indices where permitted, and target-width differences.
  • Existing opaque-pointer and GEP safety invariants remain documented and valid.

Activity

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

    bugA problem that causes incorrect behavior or crashes.help wantedThe issue requires extra attention or help from others.needs testingIssues that require additional testing or verification.technical debtIssues that represent potential future improvements or problems.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions