Skip to content

Commit 1cc6bc8

Browse files
committed
address feedback
1 parent 9b69a3b commit 1cc6bc8

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

packages/svelte/src/compiler/errors.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ export function store_invalid_subscription_module(node) {
475475
* @returns {never}
476476
*/
477477
export function trace_rune_duplicate(node) {
478-
e(node, "trace_rune_duplicate", "`$inspect.trace` must only be used once within the same block statement");
478+
e(node, "trace_rune_duplicate", `\`$inspect.trace\` must only be used once within the same block statement\nhttps://svelte.dev/e/trace_rune_duplicate`);
479479
}
480480

481481
/**
@@ -484,7 +484,7 @@ export function trace_rune_duplicate(node) {
484484
* @returns {never}
485485
*/
486486
export function trace_rune_invalid_argument(node) {
487-
e(node, "trace_rune_invalid_argument", "`$inspect.trace` requires a string argument for the trace name");
487+
e(node, "trace_rune_invalid_argument", `\`$inspect.trace\` requires a string argument for the trace name\nhttps://svelte.dev/e/trace_rune_invalid_argument`);
488488
}
489489

490490
/**
@@ -493,7 +493,7 @@ export function trace_rune_invalid_argument(node) {
493493
* @returns {never}
494494
*/
495495
export function trace_rune_invalid_location(node) {
496-
e(node, "trace_rune_invalid_location", "`$inspect.trace` must be placed directly inside a block statement");
496+
e(node, "trace_rune_invalid_location", `\`$inspect.trace\` must be placed directly inside a block statement\nhttps://svelte.dev/e/trace_rune_invalid_location`);
497497
}
498498

499499
/**
@@ -1590,4 +1590,4 @@ export function unexpected_reserved_word(node, word) {
15901590
*/
15911591
export function void_element_invalid_content(node) {
15921592
e(node, "void_element_invalid_content", `Void elements cannot have children or closing tags\nhttps://svelte.dev/e/void_element_invalid_content`);
1593-
}
1593+
}

packages/svelte/src/compiler/phases/2-analyze/visitors/CallExpression.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,15 @@ export function CallExpression(node, context) {
143143
if (node.arguments[0].type !== 'Literal' || typeof node.arguments[0].value !== 'string') {
144144
e.trace_rune_invalid_argument(node);
145145
}
146-
if (parent.type !== 'ExpressionStatement' || context.path.at(-2)?.type !== 'BlockStatement') {
146+
if (
147+
parent.type !== 'ExpressionStatement' ||
148+
context.path.at(-2)?.type !== 'BlockStatement' ||
149+
!(
150+
context.path.at(-3)?.type === 'FunctionDeclaration' ||
151+
context.path.at(-3)?.type === 'FunctionExpression' ||
152+
context.path.at(-3)?.type === 'ArrowFunctionExpression'
153+
)
154+
) {
147155
e.trace_rune_invalid_location(node);
148156
}
149157
if (context.state.scope.tracing) {

0 commit comments

Comments
 (0)