Skip to content

Resolve type aliases before indexing, dereferencing, and field access #709

Closed

Description

@LunaStev

Problem

Semantic validation rejects array indexing, pointer indexing/dereferencing, and struct field access through type aliases. Replacing each alias with its underlying type makes the same operation compile and run successfully. This breaks the transparent-alias behavior described in #166.

The IndexAccess, Deref, and FieldAccess paths in front/parser/src/verification.rs inspect types without consistently resolving aliases.

Reproduction

Save as repro.wave:

type Values = array<i32, 2>;
fun main() -> i32 {
    var values: Values = [10, 20];
    return values[1] - 20;
}
target/release/wavec build repro.wave -O0 --run
target/release/wavec build repro.wave -O2 --run

Use a compiler built from the revision below.

Tested at 01955d715dda275de993948037091140bb859174 on Fedora Linux 43, x86_64, with LLVM 21.1.8, at both -O0 and -O2.

Expected: both commands compile and exit 0. Actual: both builds exit 1 with:

error[E3001]: semantic validation failed: index access requires an array or pointer, found `Values`

The same checks reject p[0] and deref p for type IntPtr = ptr<i32>, and p.value for an alias of a struct containing that field. Direct underlying-type controls pass at both optimization levels.

Completion criteria

  • Resolve aliases consistently before validating these access operations.
  • Cover direct, chained, and imported aliases of arrays, pointers, and structs in reads and writes.
  • Add frontend and O0/O2 runtime regressions that behave identically to the underlying types.
  • Preserve diagnostics for genuinely invalid indexing, dereferencing, and field access.

Difficulty: medium.

Activity

  1. added
    bug
    help wanted
    needs testing
    on Sep 24, 2026
  2. changed the title [-][Bug]: Resolve type aliases before indexing, dereferencing, and field access[/-] [+]Resolve type aliases before indexing, dereferencing, and field access[/+] on Sep 24, 2026
  3. self-assigned this
    on Sep 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bughelp wantedneeds testing

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions