Skip to content

Reject duplicate parameter names instead of overwriting bindings #48

Closed

Description

@LunaStev

Current evidence

Audit baseline: master 3ac33ec1, after #11. Source: ir/src/lower_ast/o0.rs:92.

Reproduced: two parameters named x generate two slots, then env.insert replaces the first binding; returning x reads only the second parameter without a diagnostic.

Reproduction

Save as repro.json and run cargo run --features socket-cli -- ir lower repro.json:

{
  "globals": [],
  "functions": [
    {
      "name": "f",
      "parameters": [
        {
          "name": "x",
          "ty": {
            "Int": {
              "bits": 32,
              "signed": true
            }
          }
        },
        {
          "name": "x",
          "ty": {
            "Int": {
              "bits": 32,
              "signed": true
            }
          }
        }
      ],
      "return_type": {
        "Int": {
          "bits": 32,
          "signed": true
        }
      },
      "body": [
        {
          "Return": {
            "Var": "x"
          }
        }
      ]
    }
  ]
}

Observed exit status: 0.

module {
  target "x86_64-whale-linux"
  datalayout { ptr=64, endian=little }

  fn @f(x: i32, x: i32) -> i32 {
  entry:
    %v2: ptr<i32> = alloca i32, align 4
    %v3: ptr<i32> = alloca i32, align 4
    store i32 %v0, ptr<i32> %v2, align 4
    store i32 %v1, ptr<i32> %v3, align 4
    %v4: i32 = load i32, ptr<i32> %v3, align 4
    ret i32 %v4
  }

}

Scope

Difficulty: easy.

Check parameter names before populating the local environment.

Completion criteria

  • Duplicate names fail before lowering a body.
  • Distinct parameter names retain their correct parameter values.
  • The diagnostic names the duplicate parameter and function.

Backlog index: #12. This issue owns only the bounded work described above.

Activity

  1. added
    bug
    good first issue
    ir
    needs testing
    priority medium
    on Sep 18, 2026
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

    buggood first issueirneeds testingpriority medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions