Skip to content

Commit ae3d8a1

Browse files
committed
better labelling
1 parent 86eab1c commit ae3d8a1

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,10 @@ export function CallExpression(node, context) {
166166
if (node.arguments[0]) {
167167
context.state.scope.tracing = b.thunk(/** @type {Expression} */ (node.arguments[0]));
168168
} else {
169-
const label = get_function_label(context.path.slice(0, -2));
169+
const label = get_function_label(context.path.slice(0, -2)) ?? 'trace';
170170
const loc = `(${locate_node(fn)})`;
171171

172-
context.state.scope.tracing = b.thunk(b.literal(label ? label + ' ' + loc : loc));
172+
context.state.scope.tracing = b.thunk(b.literal(label + ' ' + loc));
173173
}
174174
}
175175

@@ -245,4 +245,8 @@ function get_function_label(nodes) {
245245
if (parent.type === 'Property' && !parent.computed) {
246246
return /** @type {Identifier} */ (parent.key).name;
247247
}
248+
249+
if (parent.type === 'VariableDeclarator' && parent.id.type === 'Identifier') {
250+
return parent.id.name;
251+
}
248252
}

0 commit comments

Comments
 (0)