vx-lang / vx-lang/Vx

A void value is treated as linear: using it twice is a move error

Open
#402 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug core-lang good first issue
Dominant language
Rust
Stars
14
Forks
2
Avg merge
12h 42m
Merged PRs (30d)
61

Description

void is spelled Type::Struct("void") (syntax/types.rs, is_void_ty), and the linearity rules consume any Type::Struct. So a valueless result behaves like an owned resource:

fn nothing() -> void { }
fn main() -> i32 {
  let z = nothing();
  let a = z;
  let b = z;
  return 0;
}
Error[E4001] at 5:11: Use of moved or consumed linear variable: z

There is nothing to move. The same rule makes a unit-valued expression (an if with no else, an empty block) report a spurious move when used twice.

Found while splitting the tensor spellings (#399). Before that work these sites answered a dims-less Tensor<f32>, which is also linear, so the behaviour predates the split and is unchanged by it — the switch to void only made the diagnostic name the type honestly instead of printing Tensor(F32, [], None) at the user.

Fix direction: exempt void/none from consumption wherever Type::Struct triggers it, or give unit its own Type variant so it cannot inherit struct rules by spelling.

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 in syntax/types.rs with Type::Struct("void") and is_void_ty, then trace the linearity path that consumes Type::Struct values. Reproduce the issue with the provided nothing() example and the unit-valued expression cases. Done means void and unit values can be used more than once without a spurious move error, while other linear structs retain their behavior.

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.