Beef icon indicating copy to clipboard operation
Beef copied to clipboard

#unwarn in emitted comptime code isn't honored

Open Grimelios opened this issue 3 months ago • 0 comments

[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!
}

Grimelios avatar Sep 11 '25 06:09 Grimelios