Skip to content

Commit f953b53

Browse files
authored
Apply suggestions from code review
1 parent c22346d commit f953b53

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

packages/svelte/src/compiler/phases/1-parse/read/expression.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ export function get_loose_identifier(parser, opening_token) {
2929
/**
3030
* @param {Parser} parser
3131
* @param {string} [opening_token]
32-
* @param {boolean} [is_each]
32+
* @param {boolean} [disallow_loose]
3333
* @returns {Expression}
3434
*/
35-
export default function read_expression(parser, opening_token, is_each) {
35+
export default function read_expression(parser, opening_token, disallow_loose) {
3636
try {
3737
const node = parse_expression_at(parser.template, parser.ts, parser.index);
3838

@@ -63,15 +63,9 @@ export default function read_expression(parser, opening_token, is_each) {
6363

6464
return /** @type {Expression} */ (node);
6565
} catch (err) {
66-
/**
67-
* If we are in an each loop we need the error to be thrown in cases like
68-
*
69-
* `as { y = z }`
70-
*
71-
* so we still throw and handle the error there
72-
*/
73-
if (parser.loose && !is_each) {
74-
// Find the next } and treat it as the end of the expression
66+
// If we are in an each loop we need the error to be thrown in cases like
67+
// `as { y = z }` so we still throw and handle the error there
68+
if (parser.loose && !disallow_loose) {
7569
const expression = get_loose_identifier(parser, opening_token);
7670
if (expression) {
7771
return expression;

0 commit comments

Comments
 (0)