Skip to content

Duplicate @ attributes produce invalid code #9693

Open
@jjonescz

Description

@jjonescz
<input @ref="@a" @ref="@b" />
@code {
    ElementReference a;
    ElementReference b;
}

Produces roughly:

__builder.OpenElement(0, "input");
__builder.AddContent(1, b);
__builder.AddAttribute(2, "@ref");
__builder.AddElementReferenceCapture(3, (__value) => { a = __value; });
__builder.CloseElement();

Notice b is produced as AddContent which won't work at runtime. No warning about duplicate @refs is emitted either.

This happens for other special attributes as well, like @formname.

See also:

public void FormName_Duplicate_CSharpValue()
{
// This emits invalid code and no warnings, but that's a pre-existing bug,
// happens with the following Razor code, too.
// <input @ref="@a" @ref="@b" />
// @code {
// ElementReference a;
// ElementReference b;
// }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-compilerUmbrella for all compiler issuesbugSomething isn't workinguntriaged

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions