Skip to content

Module-qualified symbols: remaining name-coincidence corners of the Julia layout and the duplicate-symbol scan (#300 follow-up) #338

Description

@terasakisatoshi

Follow-up to #300 / #333, recorded as a scope decision on that PR. Each item is a name coincidence — a user-chosen identifier that spells something RustCall generates or imports — that #333 does not detect. None affects a crate whose names do not collide; all should fail closed with a message rather than reach rustc / Julia as a duplicate definition.

Raised by Codex on #333 round 4:

  1. Manifest::symbol_owners lists primary symbols only. A crate-root #[julia] fn a__run_take_panic() next to #[julia] mod a { #[julia] fn run } makes the root wrapper's entry symbol equal to a::run's panic reader (rustcall_a__run_take_panic); claim_symbols in rustcall-extract does not see it. Include every derived export — <symbol>_take_panic, __RUSTCALL_PANIC_<SYMBOL>, <owner>_RustCallOwnedString / _free_rust_string / _RustCallBorrowedString, <stem>_clone — the way pyo3::wrapper_symbols / string_helper_symbols already do for the PyO3 scan. Best done by sharing one "every symbol this entry claims" function between the two.
  2. Inline expansion has no crate-wide symbol check. expand::symbol_collisions is lexical-module-local; a rust""" block with root #[julia] fn a__run() and mod a { #[julia] fn run } reaches rustc with two rustcall_a__run. Run the same crate-wide check (item 1) over the expanded manifest and emit a compile_error! naming both items.
  3. _check_module_names checks child-module names only. Rust allows #[julia] fn C() and #[julia] struct C in one module (value vs. type namespace); the Julia emitters define function C then mutable struct C. Detect collisions among the bindings accumulated within a node (functions, structs, methods, accessors), not only against child modules. This also covers the pre-existing crate-root case.
  4. Names implicitly imported from Base. A child module named like a Base export (String, Vector, println, …) passes _julia_module_name; module String inside the generated module conflicts with the implicit using Base. Reserve names(Base) (and Core) in _check_module_names, or map such module names.

Tests to add alongside: deps/rustcall_core/tests/symbols.rs (1, 2), test/test_module_symbols.jl (3, 4).

🤖 Generated with Claude Code

https://claude.ai/code/session_014iJ1dZ7KEebWDjdY7fhPbw

Activity

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

    area:codegenrustcall_core, proc-macro, extractor, manifest

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions