@@ -342,126 +342,124 @@ class Evaluation {
342342 break ;
343343 }
344344
345- case 'CallExpression' :
346- {
347- const rune = get_rune ( expression , scope ) ;
348- if ( rune ) {
349- switch ( rune ) {
350- case '$state' :
351- case '$state.raw' :
352- if ( expression . arguments . length ) {
353- const evaluated = scope . evaluate (
354- /** @type {Expression } */ ( expression . arguments [ 0 ] )
355- ) ;
356- for ( let value of evaluated . values ) {
357- this . values . add ( value ) ;
358- }
359- } else {
360- this . values . add ( undefined ) ;
361- }
362- break ;
363-
364- case '$props.id' :
365- this . values . add ( STRING ) ;
366- break ;
367-
368- case '$effect.tracking' :
369- this . values . add ( false ) ;
370- this . values . add ( true ) ;
371- break ;
372-
373- case '$derived' : {
345+ case 'CallExpression' : {
346+ const rune = get_rune ( expression , scope ) ;
347+ if ( rune ) {
348+ switch ( rune ) {
349+ case '$state' :
350+ case '$state.raw' :
351+ if ( expression . arguments . length ) {
374352 const evaluated = scope . evaluate (
375353 /** @type {Expression } */ ( expression . arguments [ 0 ] )
376354 ) ;
377355 for ( let value of evaluated . values ) {
378356 this . values . add ( value ) ;
379357 }
380- break ;
358+ } else {
359+ this . values . add ( undefined ) ;
381360 }
361+ break ;
382362
383- case '$derived.by' :
384- if ( expression . arguments [ 0 ] ?. type === 'ArrowFunctionExpression' ) {
385- if ( expression . arguments [ 0 ] . body ?. type !== 'BlockStatement' ) {
386- const evaluated = scope . evaluate (
387- /** @type {Expression } */ ( expression . arguments [ 0 ] . body )
388- ) ;
389- for ( let value of evaluated . values ) {
390- this . values . add ( value ) ;
391- }
392- break ;
363+ case '$props.id' :
364+ this . values . add ( STRING ) ;
365+ break ;
366+
367+ case '$effect.tracking' :
368+ this . values . add ( false ) ;
369+ this . values . add ( true ) ;
370+ break ;
371+
372+ case '$derived' : {
373+ const evaluated = scope . evaluate ( /** @type {Expression } */ ( expression . arguments [ 0 ] ) ) ;
374+ for ( let value of evaluated . values ) {
375+ this . values . add ( value ) ;
376+ }
377+ break ;
378+ }
379+
380+ case '$derived.by' :
381+ if ( expression . arguments [ 0 ] ?. type === 'ArrowFunctionExpression' ) {
382+ if ( expression . arguments [ 0 ] . body ?. type !== 'BlockStatement' ) {
383+ const evaluated = scope . evaluate (
384+ /** @type {Expression } */ ( expression . arguments [ 0 ] . body )
385+ ) ;
386+ for ( let value of evaluated . values ) {
387+ this . values . add ( value ) ;
393388 }
389+ break ;
394390 }
391+ }
395392
396- this . values . add ( UNKNOWN ) ;
397- break ;
393+ this . values . add ( UNKNOWN ) ;
394+ break ;
398395
399- default : {
400- this . values . add ( UNKNOWN ) ;
401- }
396+ default : {
397+ this . values . add ( UNKNOWN ) ;
402398 }
403- } else if (
404- expression . callee . type === 'Identifier' &&
405- scope . get ( expression . callee . name ) === null
406- ) {
407- switch ( expression . callee . name ) {
408- case 'Number' : {
409- if ( expression . arguments . length ) {
410- const arg = scope . evaluate ( /** @type { Expression } */ ( expression . arguments [ 0 ] ) ) ;
411- if ( arg . is_known ) {
412- this . values . add ( Number ( arg . value ) ) ;
413- } else if ( arg . is_number ) {
414- this . values . add ( NUMBER ) ;
415- } else {
416- for ( let value of arg . values ) {
417- switch ( value ) {
418- case STRING :
419- case NUMBER :
420- case UNKNOWN :
421- this . values . add ( NUMBER ) ;
422- break ;
423- default :
424- this . values . add ( Number ( value ) ) ;
425- }
399+ }
400+ } else if (
401+ expression . callee . type === 'Identifier' &&
402+ scope . get ( expression . callee . name ) === null
403+ ) {
404+ switch ( expression . callee . name ) {
405+ case 'Number' : {
406+ if ( expression . arguments . length ) {
407+ const arg = scope . evaluate ( /** @type { Expression } */ ( expression . arguments [ 0 ] ) ) ;
408+ if ( arg . is_known ) {
409+ this . values . add ( Number ( arg . value ) ) ;
410+ } else if ( arg . is_number ) {
411+ this . values . add ( NUMBER ) ;
412+ } else {
413+ for ( let value of arg . values ) {
414+ switch ( value ) {
415+ case STRING :
416+ case NUMBER :
417+ case UNKNOWN :
418+ this . values . add ( NUMBER ) ;
419+ break ;
420+ default :
421+ this . values . add ( Number ( value ) ) ;
426422 }
427423 }
428- } else {
429- this . values . add ( 0 ) ;
430424 }
431- break ;
425+ } else {
426+ this . values . add ( 0 ) ;
432427 }
433- case 'String' :
434- if ( expression . arguments . length ) {
435- const arg = scope . evaluate ( /** @type {Expression } */ ( expression . arguments [ 0 ] ) ) ;
436- if ( arg . is_known ) {
437- this . values . add ( String ( arg . value ) ) ;
438- } else if ( arg . is_number || arg . is_string ) {
439- this . values . add ( STRING ) ;
440- } else {
441- for ( let value of arg . values ) {
442- switch ( value ) {
443- case STRING :
444- case NUMBER :
445- case UNKNOWN :
446- this . values . add ( STRING ) ;
447- break ;
448- default :
449- this . values . add ( String ( value ) ) ;
450- }
428+ break ;
429+ }
430+ case 'String' :
431+ if ( expression . arguments . length ) {
432+ const arg = scope . evaluate ( /** @type {Expression } */ ( expression . arguments [ 0 ] ) ) ;
433+ if ( arg . is_known ) {
434+ this . values . add ( String ( arg . value ) ) ;
435+ } else if ( arg . is_number || arg . is_string ) {
436+ this . values . add ( STRING ) ;
437+ } else {
438+ for ( let value of arg . values ) {
439+ switch ( value ) {
440+ case STRING :
441+ case NUMBER :
442+ case UNKNOWN :
443+ this . values . add ( STRING ) ;
444+ break ;
445+ default :
446+ this . values . add ( String ( value ) ) ;
451447 }
452448 }
453- } else {
454- this . values . add ( '' ) ;
455449 }
456- break ;
457- default :
458- this . values . add ( UNKNOWN ) ;
459- }
460- } else {
461- this . values . add ( UNKNOWN ) ;
450+ } else {
451+ this . values . add ( '' ) ;
452+ }
453+ break ;
454+ default :
455+ this . values . add ( UNKNOWN ) ;
462456 }
457+ } else {
458+ this . values . add ( UNKNOWN ) ;
463459 }
460+
464461 break ;
462+ }
465463
466464 default : {
467465 this . values . add ( UNKNOWN ) ;
0 commit comments