Skip to content

Commit a58d2df

Browse files
committed
lint
1 parent bb95f5a commit a58d2df

File tree

1 file changed

+5
-5
lines changed
  • packages/svelte/src/compiler/phases

1 file changed

+5
-5
lines changed

packages/svelte/src/compiler/phases/scope.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,25 +1698,25 @@ function evaluate_function(fn, binding, stack = new Set(), [...seen_bindings] =
16981698
/**
16991699
* This big blob of comments is for my (https://github.com/Ocean-OS) sanity and for that of anyone who tries working with this function. Feel free to modify this as the function evolves.
17001700
* So, when evaluating functions at compile-time, there are a few things you have to avoid evaluating:
1701-
*
1701+
*
17021702
* - Side effects
17031703
* A function that modifies state from outside of its scope should not be evaluated.
17041704
* Additionally, since `$effect`s and `$derived`s exist, any reference to an external value could lead to a missed dependency if the function is evaluated by the compiler.
17051705
* - Errors
17061706
* A function that could throw an error should not be evaluated. Additionally, `$derived`s could be reevaluated upon reading, which could throw an error.
17071707
* The purpose of a compile-time evaluator is to replicate the behavior the function would have at runtime, but in compile time.
17081708
* If an error is/could be thrown, that can not be replicated.
1709-
*
1709+
*
17101710
* So, how do we figure out if either of these things (could) happen in a function?
17111711
* Well, for errors, it's relatively simple. If a `throw` statement is used in the function, then we assume that the error could be thrown at any time.
17121712
* For side effects, it gets a bit tricky. External `Identifier`s that change their value are definitely side effects, but also any `MemberExpression` that isn't a known global constant could have a side effect, due to getters and `Proxy`s.
17131713
* Additionally, since a function can call other functions, we check each individual function call: if it's a known global, we know its pure, and if we can find its definition, the parent function inherits its throwability and purity. If we cannot find its definition, we assume it is impure and could throw.
1714-
*
1714+
*
17151715
* A few other things to note/remember:
17161716
* - Not all functions rely on return statements to determine the return value.
17171717
* Arrow functions without a `BlockStatement` for a body use their expression body as an implicit `ReturnStatement`.
17181718
* - While currently all the globals we have are pure and error-free, that could change, so we shouldn't be too dependent on that in the future.
1719-
* Things like `JSON.stringify` and a *lot* of array methods are prime examples.
1719+
* Things like `JSON.stringify` and a *lot* of array methods are prime examples.
17201720
*/
17211721
let thing;
17221722
const analysis = {
@@ -1811,7 +1811,7 @@ function evaluate_function(fn, binding, stack = new Set(), [...seen_bindings] =
18111811
}
18121812
if (
18131813
binding.scope !== fn_scope &&
1814-
!binding.updated &&
1814+
!binding.updated &&
18151815
context.state.current_call === 0 &&
18161816
!seen_bindings.includes(binding)
18171817
) {

0 commit comments

Comments
 (0)