Skip to content

D184 WIP: a comprehension over a map global in a script lowers v * 2 with v as a pointer (LLVM: "Call parameter type does not match"); audit:resolution stayed silent #2978

Closed

Description

@ehartford

On branch d184-script-globals (worktree ~/.local/with-staging/stack2, commit 7d08eb429), reduced from behav_d44_map_traversal_views:

use std.collections
var m: HashMap[str, i32] = HashMap.new()
m.insert("alpha".to_owned(), 1)
let doubled = [v * 2 for (k, v) in m]
print(f"{doubled:?}")
Call parameter type does not match function signature!
i32 2
 ptr  %106 = call { ptr, i1 } @llvm.smul.with.overflow.p0(ptr …, i32 2)
error: LLVM function verification failed after MIR cleanup for main

With an explicit fn main holding the same statements over a module-level var m it compiles and runs. Under D184 doubled is itself a script global: its initializer (the comprehension, whose (k, v) are &K/&V views, D44) is type-checked in the decl pass as a global initializer and lowered in main by the script-init statement; the view-to-value materialization of v (D22) does not reach that lowering, so v * 2 multiplies the pointer. The main MIR shows the comprehension's iterator types numbered from the decl pass (ty1640…) where the explicit-main variant has main's (ty6452…).

with analyze repro.w audit:resolution reports violations=0 ok on this program, so the operand-type check misses a MIR operand whose type is not what Sema gave the expression; that silence is a bug of its own (AGENTS.md: a tool that stayed silent).

Likely fix shape: check a script-init initializer in main's body context (as the statement that assigns the global), typing the global from it on demand for helpers checked earlier, instead of checking it as a D175 initializer body and lowering it elsewhere.

Activity

  1. added
    bug
    on Nov 2, 2026
  2. added a commit that references this issue on Nov 7, 2026
  3. ehartford commented on Nov 7, 2026

    @ehartford
    ContributorAuthor

    Already fixed on main by the D184 landing (the repro prints [2] under the installed compiler); pinned in #3064 by test/behavior/behav_2978_script_map_comprehension.w.

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions