Skip to content

D70: a namespaced type that another visible declaration shadows is refused (shapes.Pt beside a local Pt) #1757

Closed

Description

@ehartford

Spec: §18.2 (D70, merged in #1752) — "Every import is also a namespace, so a shadowed name stays reachable."

On branch ruled-fixes (PR #1751) a namespace reaches a module's values, fns and consts by identity: a colliding declaration of another module is displaced to its module-qualified symbol (#1703) and ns.member is rewritten to that symbol. Types are not displaced — they keep their short name and resolve through the D29 tier candidates — so shapes.Pt is rewritten to Pt only when Pt already resolves to shapes' type here. Where it does not (this module or a later import declares its own Pt), Sema refuses it loudly:

use d70.shapes
type Pt { y: str }
fn main:
    let q = shapes.Pt.new(5)

error: 'shapes.Pt' names module '…/shapes.w's type, but 'Pt' here resolves to another declaration; a namespaced type that another visible declaration shadows is not reachable yet (D70) (pinned by test/compile_errors/err_d70_namespaced_type_shadowed.w).

Expected: shapes.Pt.new(5) constructs shapes' Pt. Needs a per-module type identity the rewritten node can carry — D70 names #751 (canonical module identity) as the foundation. When it lands, turn the pinned error test into a behavior test.

A namespaced type annotation (let c: shapes.Pt) already resolves through the type-expression path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions