Skip to content

fix: improve partial evaluation #15781

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

Merged
merged 26 commits into from
Apr 18, 2025
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
  • Loading branch information
Rich-Harris authored Apr 17, 2025
commit 9325dc117dfa80c9965ebb9b2027e5b433fd3877
28 changes: 2 additions & 26 deletions packages/svelte/src/compiler/phases/scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,20 +407,8 @@ class Evaluation {
const arg = scope.evaluate(/** @type {Expression} */ (expression.arguments[0]));
if (arg.is_known) {
this.values.add(Number(arg.value));
} else if (arg.is_number) {
this.values.add(NUMBER);
} else {
for (let value of arg.values) {
switch (value) {
case STRING:
case NUMBER:
case UNKNOWN:
this.values.add(NUMBER);
break;
default:
this.values.add(Number(value));
}
}
this.values.add(NUMBER);
}
} else {
this.values.add(0);
Expand All @@ -432,20 +420,8 @@ class Evaluation {
const arg = scope.evaluate(/** @type {Expression} */ (expression.arguments[0]));
if (arg.is_known) {
this.values.add(String(arg.value));
} else if (arg.is_number || arg.is_string) {
this.values.add(STRING);
} else {
for (let value of arg.values) {
switch (value) {
case STRING:
case NUMBER:
case UNKNOWN:
this.values.add(STRING);
break;
default:
this.values.add(String(value));
}
}
this.values.add(STRING);
}
} else {
this.values.add('');
Expand Down