Skip to content

Commit 6e67012

Browse files
fix
1 parent 2d1c020 commit 6e67012

File tree

1 file changed

+14
-13
lines changed
  • crates/djls-semantic/src/semantic

1 file changed

+14
-13
lines changed

crates/djls-semantic/src/semantic/args.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,8 @@ fn validate_choices_and_order(
216216

217217
// Consume tokens greedily until we hit a known literal
218218
while bit_index < bits.len() {
219-
if let Some(ref lit) = next_literal {
220-
if bits[bit_index] == *lit {
219+
if let Some(lit) = next_literal {
220+
if bits[bit_index] == lit {
221221
break; // Stop before the literal
222222
}
223223
}
@@ -238,6 +238,12 @@ fn validate_choices_and_order(
238238
let next_literal = find_next_literal(&args[arg_index + 1..]);
239239

240240
while bit_index < bits.len() {
241+
if let Some(lit) = next_literal {
242+
if bits[bit_index] == lit {
243+
break;
244+
}
245+
}
246+
241247
let token = &bits[bit_index];
242248
bit_index += 1;
243249

@@ -247,16 +253,11 @@ fn validate_choices_and_order(
247253
}
248254

249255
// If we hit "as", consume one more token (the variable name)
250-
if token == "as" && bit_index < bits.len() {
251-
bit_index += 1;
252-
break;
253-
}
254-
255-
// Stop if we hit next literal
256-
if let Some(ref lit) = next_literal {
257-
if token == lit {
258-
break;
256+
if token == "as" {
257+
if bit_index < bits.len() {
258+
bit_index += 1;
259259
}
260+
break;
260261
}
261262
}
262263
}
@@ -306,10 +307,10 @@ fn argument_name(arg: &TagArg) -> String {
306307

307308
/// Find the next literal keyword in the argument list.
308309
/// This helps expression arguments know when to stop consuming tokens.
309-
fn find_next_literal(remaining_args: &[TagArg]) -> Option<String> {
310+
fn find_next_literal(remaining_args: &[TagArg]) -> Option<&str> {
310311
for arg in remaining_args {
311312
if let TagArg::Literal { lit, .. } = arg {
312-
return Some(lit.to_string());
313+
return Some(lit.as_ref());
313314
}
314315
}
315316
None

0 commit comments

Comments
 (0)