Skip to content

Submodules can be shadowed by unrelated modules #209

@elpinal

Description

@elpinal

test.saty:

module M = struct
  module N = struct
    let x = 1
  end
end

module N = struct end

let z = M.N.x

Typechecking test.saty results in the following error message:

! [Type Error] at "test.saty", line 9, characters 8-13:
    undefined variable 'M.N.x'.

The reason may be that Typeenv.t contains name_to_id_map as a mapping from module names to module ids, not as a mapping from sequences of module names to module ids.

type name_to_id_map = ModuleID.t ModuleNameMap.t

let find (tyenv : t) (mdlnmlst : module_name list) (varnm : var_name) (rng : Range.t) : (poly_type * EvalVarID.t * stage) option =
let open OptionMonad in
let nmtoid = tyenv.name_to_id_map in
let mtr = tyenv.main_tree in
let addrlst = Alist.to_list tyenv.current_address in
let addrlast =
mdlnmlst |> List.map (fun nm ->
match nmtoid |> ModuleNameMap.find_opt nm with
| None -> raise (UndefinedModuleName(rng, nm, get_candidates ModuleNameMap.fold nmtoid nm))
| Some(mdlid) -> mdlid
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions