-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
fix: error for rune usage in {@const} tag initialization #15044
Conversation
🦋 Changeset detectedLatest commit: 15e2e0f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
preview: https://svelte-dev-git-preview-svelte-15044-svelte.vercel.app/ this is an automated message |
|
for (let declaration of node.declaration.declarations) { | ||
const rune = get_rune(declaration.init, context.state.scope); | ||
if (rune) { | ||
e.const_tag_invalid_rune_usage(declaration.init, rune); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we start with the more generic "rune X cannot be used here" errors that already exist? that way we don't need to invent another error code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh i knew we had an error like this...i tried to search for it and miserably failed 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh actually we don't have a generic one...we only have specific ones (i think)...i'll check better after TWIS!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah confirmed there's no generic rune X cannot be used here
...should we create a generic error like this instead of the specific one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thinking was that you check which rune it is and then throw one of the more specific "X can only be used at ..." errors - I haven't checked the error message itself though, so if you find that's not possible then yes maybe a more generic error message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah the other error messages are very specific... I'll create a rune_cannot_be_used error
This doesn't seem right to me. It should be totally fine to do this for example: {#snippet test()}
{@const der = $state.snapshot(blah)}
{/snippet} Let's just fix up the existing logic around |
Opened #15115 |
@Rich-Harris this seems to be disallowed in 5.19.3 |
never mind, I clicked your original link and saw "running Svelte compiler version 5.19.3" in the console but forgot to look at the URL, which contained |
Closes #15042
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint