Is this identifer shadowing report necessary?

The outer content can’t be used in the bar function, if it is not of comptime.

const std = @import("std");

fn foo(content: []const u8) void {
    const T = struct {
        // error: function parameter 'content' shadows function parameter from outer scope
        fn bar(_: @This(), content: []const u8) void {
            std.debug.print(">> {s}\n", .{content});
        }
    };
    
    const t = T{};
    t.bar(content[0..3]);
}

pub fn main() !void {
    foo("abcde");
}

The runtime value cannot be used, but that is not the only thing that can be done with the identifier: @TypeOf(content)

5 Likes