Skip to content

compiler errors without squiggling when attribute contains @() blocks without space #9985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AdmiralSnyder opened this issue Feb 24, 2024 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@AdmiralSnyder
Copy link

In a razor file, i have an element with an attribute, and in that, there are two @() blocks containing something - if those blocks aren't separated by a string, compilation fails, but there's no squiggle in the editor. See screenshot
image

@davidwengier
Copy link
Member

there's no squiggle in the editor

This would be tooling, but looks to me like the compiler shouldn't be erroring on this, or perhaps should be offering a better RZ diagnostic if this scenario isn't supported, so moving to compiler to have a first look.

@davidwengier davidwengier added the area-compiler Umbrella for all compiler issues label Feb 24, 2024
@jjonescz
Copy link
Member

jjonescz commented Feb 26, 2024

I think the compiler's behavior here is by design - all consecutive C# expressions are concatenated and treated as one expression. For example,

<input value="@(1+)@(2)" />

will render as

<input value="3" />

Changing that would be a breaking change. So in the original example, @("HELLO")@("WORLD") is translated to C# "HELLO""WORLD" which gives those errors. And the compiler cannot report a better RZ diagnostic here as it doesn't know whether there's an error in the first place.

@davidwengier
Copy link
Member

davidwengier commented Feb 26, 2024

That is bizarre and scary, I had no idea. Would love to see that change in a warning wave, as I can see why someone might want @(myThing.Name)@(myThing.Suffix) for example, but I'm failng to see the benefit of @(1+)@(2). Especially considering interpolated strings in Razor are only accidental.

<input value="@(1+)@(2)" /> is angry_jaredpar worthy 😁

@chsienki chsienki removed the area-compiler Umbrella for all compiler issues label Mar 12, 2024
@chsienki
Copy link
Member

@phil-allen-msft Compiler is working as expected, so moving to tooling for triage of the squiggles not showing.

@ryzngard ryzngard added the bug Something isn't working label Apr 11, 2024
@ryzngard ryzngard added this to the Backlog milestone Apr 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants