Skip to content

#unwarn in emitted comptime code isn't honored #2318

@Grimelios

Description

@Grimelios
[Comptime(ConstEval = true)]
public static void UsesUnwarn()
{
    Compiler.MixinRoot("""
        #unwarn
        let field = 123;
    """);
}

public static void Main()
{
    UsesUnwarn();
    UsesUnwarn(); // A variable named 'field' has already been declared in this scope
}

Tested on 09/09/2025. The code above warns about the variable field being reused despite #unwarn being included in the code emitted by the comptime method UsesUnwarn. Per Discord discussion, this is a bug. Manually adding #unwarn successfully hides the warning:

public static void Main()
{
    UsesUnwarn();
#unwarn
    UsesUnwarn(); // The warning is gone!
}

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