Skip to content

lib: qualify enum/interface/alias identity, field pub, import cycles - #219

Merged
dslsdzc merged 1 commit into
developfrom
lib-qualified-types-fields-imports
Oct 27, 2026
Merged

dslsdzc merged 1 commit into
developfrom
lib-qualified-types-fields-imports

Conversation

@dslsdzc

@dslsdzc dslsdzc commented Oct 27, 2026

Copy link
Copy Markdown
Owner

概要

补齐同名身份的剩余类型、字段级 pub 与 import 图身份。

1. enum / interface / type alias 身份

assign_unique_*_names 对四类声明做同样的跨库同名检测:冲突声明得到内部唯一名,符号/导出保留源名,TYP_NAMED 使用唯一名。find_enum/find_iface 经可见性感知的符号解析;impl 边重映射到限定名。

2. 字段级 pub

parser 接受字段尾部标签 , pub / , mut / , apx。字段默认库内私有;pub 结构体的字段需要 , pub 才能跨库读写、字面量构造和模式访问。MemLayout 的四个字段标 pub;Bits32/IntMap 内部字段保持私有。

3. import 图

  • 导入主文件 → error: import cycle: '...' resolves to the entry file。
  • 已加载兄弟文件按规范化路径去重(菱形导入不再重复定义)。

判据

  • 用户与 stdlib 同时声明 ShownEnum / ShownAlias / ShownIface:各自绑定自己的声明,运行 42。
  • import bits 后读 Bits32.value → N03;stdpub MemLayout 字段可读。
  • import 主文件 → cycle;菱形导入运行 42。
  • selfhost-tests / bootstrap-tests / check 全绿;canary 5/5 不变。

- Extend the declaration map to enums, interfaces and type aliases. Each
  colliding declaration gets an internal unique name; symbols/exports keep the
  source name and TYP_NAMED carries the unique identity. find_enum/find_iface
  resolve through the visibility-aware symbol and handle unique names; impl
  edges are remapped to the qualified names.
- Field-level pub: parser accepts field tail tags (pub/mut/apx); fields default
  to library-internal. Cross-library field reads/writes, struct literals and
  patterns treat a non-pub field as unknown (N03/TS02). MemLayout fields are
  marked pub; Bits32/IntMap internals stay private.
- Import graph: importing the entry file reports a cycle instead of loading it
  twice; already-loaded sibling paths are diamond-deduplicated.
- Type self-test pins g_cur_lib = -1 so declaration-table lookups keep their
  direct semantics.
- Docs/tests updated. Selfhost/bootstrap/check green; canary 5/5 unchanged.
@dslsdzc
dslsdzc merged commit be89425 into develop Oct 27, 2026
4 checks passed
@dslsdzc
dslsdzc deleted the lib-qualified-types-fields-imports branch October 27, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant