Repository navigation
lib: give colliding functions and methods library-qualified link names - #218
Merged
Merged
Conversation
Source names remain the lookup and export key; IR_CALL and the .ccr function table now carry a link name. When two libraries declare the same function or method name, each declaration gets a unique link name, so the call target is no longer ambiguous at the codegen/link boundary. - g_func_link parallel table; add_func defaults it to the source name. - Cross-library collisions get name@lib#fnN links; monomorph instances inherit the qualified prefix. - Checker writes the resolved link into the call node; IR direct calls prefer it, method calls use it in node data, and dyn dispatch stores the method name (not a link). - find_func falls back to link names for IR-side queries; function SYM rows and cache-hit metadata use the link, while symbols/exports stay source-named. - Interpolation rewrites and direct-call sentinel fixed for the new node data. Tests: user fpow2i and print shadow stdlib names; user IntMap.put coexists with hashmap IntMap.put and both dispatch to their own bodies. Canary 5/5 unchanged; selfhost/bootstrap/check green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
上一批(#217)让 struct/global 同名声明拥有独立身份,但函数/方法同名仍按 N11 拒绝:
IR_CALL和.ccr函数表只有源名,两个同名函数在链接面无法区分。修法
g_func_link平行表;add_func默认 link = 源名。name@lib#fnNlink;monomorph 实例继承限定前缀。IR_CALL、函数 SYM 行、.cir缓存元数据使用 link。dyn分派存方法名而不是 link。find_func增加 link 回退,供 IR 侧查询;符号/导出保持源名。判据
fn fpow2i遮蔽 stdlib 非 pub 内部名:编译并返回 42。fn print遮蔽io.print,stdlibprintln仍走自己的 print(输出 hello)。impl IntMap.put与hashmap.IntMap.put并存:两者各自调用自己的函数体,组合用例返回 42。selfhost-tests/bootstrap-tests/check全绿。canary5/5 不变。