Rust-GCC / Rust-GCC/gccrs

Missing name resolution error for environment captures in inner functions

Open
#2,296 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
2.9k
Forks
231
Avg merge
19h 55m
Merged PRs (30d)
67

Description

I tried this code:

fn foobi(a: i32) {
    fn boofi() -> i32 {
        a
    }
}

I expected to see this happen:

error[E0434]: can't capture dynamic environment in a fn item
 --> test.rs:3:9
  |
3 |         a
  |         ^
  |
  = help: use the `|| { ... }` closure form instead

Instead, this happened: no error

This is invalid, since the name resolution rules state that only closures are able to access their outer environment, not inner functions.

Meta
  • What version of Rust GCC were you using, git sha if possible.

e8d00353017

Contributor guide

Open the contributing guide

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 compiling the provided Rust snippet with gccrs and compare its diagnostics with the expected E0434 error. Trace name resolution for the inner fn boofi and its reference to a; done means the invalid environment capture is diagnosed consistently with the shown message.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.