Skip to content

current_fn_name Mutable State on Compiler #172

@0xGeorgii

Description

@0xGeorgii

current_fn_name: String is set at the start of visit_function_definition and read inside lower_sret_return. This is an ambient context — a value implicitly available rather than explicitly threaded through the call chain. Industrial compilers (rustc, LLVM, Zig) thread function context explicitly via a FnCtxt or parameter.

Currently tolerable because it is only read in one place (lower_sret_return), and the data flow is clear: visit_function_definitionlower_statementlower_sret_return.

  • Fix: Thread fn_name: &str as a parameter, or fold it into a LoweringContext struct alongside frame_layout, locals_map, and other per-function state.
    • Trigger: When adding method compilation, incremental compilation, or parallel function compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenBytecode emitting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions