vx-lang / vx-lang/Vx

`(&mut t[i][j]).as_mut_ptr()` crashes the compiler

Open
#421 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug codegen
Dominant language
Rust
Stars
14
Forks
2
Avg merge
12h 42m
Merged PRs (30d)
61

Description

fn main() -> i32 {
  let mut c = Tensor<f32>([2, 2]);
  c[0][0] = 1.0;
  let pc = (&mut c[0][0]).as_mut_ptr();
  return 0;
}
[flat-codegen] declined main: no flat lowering for the MethodCall expression [unsupported-expr(MethodCall)]
[flat-codegen] program outside the flat subset; using the AST path
Vx Compiler Internal Error: panicked at src/codegen/lower/expr.rs:2727:13:
Function as_mut_ptr not found

The checker accepts as_mut_ptr on a borrow of a tensor element and gives it a type; the AST lowering then looks for a function of that name, does not find one, and panics. Either the checker should reject the receiver or the lowering should handle it, but a program a user can write should not reach an unreachable-style panic — same shape as the mlir! parse panic in Vx#414.

as_mut_ptr on the tensor itself is handled and yields *mut Tensor<f32, [2, 2]>; only the element-borrow receiver falls through.

Found while probing the aliasing premise in the issue above.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided Vx reproduction, then inspect src/codegen/lower/expr.rs around the reported panic and the checker handling for as_mut_ptr on a borrowed tensor element. Done means this valid program no longer reaches the compiler panic: it is either rejected by the checker or lowered successfully, with coverage for the receiver distinction.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.