File tree Expand file tree Collapse file tree 1 file changed +12
-21
lines changed
packages/svelte/src/compiler/phases Expand file tree Collapse file tree 1 file changed +12
-21
lines changed Original file line number Diff line number Diff line change @@ -392,30 +392,21 @@ class Evaluation {
392392 if ( expression . callee . type === 'Identifier' && scope . get ( expression . callee . name ) === null ) {
393393 switch ( expression . callee . name ) {
394394 case 'Number' : {
395- if ( expression . arguments . length ) {
396- const arg = scope . evaluate ( /** @type {Expression } */ ( expression . arguments [ 0 ] ) ) ;
397- if ( arg . is_known ) {
398- this . values . add ( Number ( arg . value ) ) ;
399- } else {
400- this . values . add ( NUMBER ) ;
401- }
402- } else {
403- this . values . add ( 0 ) ;
404- }
395+ const arg = /** @type {Expression | undefined } */ ( expression . arguments [ 0 ] ) ;
396+ const e = arg && scope . evaluate ( arg ) ;
397+
398+ this . values . add ( e ? ( e . is_known ? Number ( e . value ) : NUMBER ) : 0 ) ;
405399 break ;
406400 }
407- case 'String' :
408- if ( expression . arguments . length ) {
409- const arg = scope . evaluate ( /** @type {Expression } */ ( expression . arguments [ 0 ] ) ) ;
410- if ( arg . is_known ) {
411- this . values . add ( String ( arg . value ) ) ;
412- } else {
413- this . values . add ( STRING ) ;
414- }
415- } else {
416- this . values . add ( '' ) ;
417- }
401+
402+ case 'String' : {
403+ const arg = /** @type {Expression | undefined } */ ( expression . arguments [ 0 ] ) ;
404+ const e = arg && scope . evaluate ( arg ) ;
405+
406+ this . values . add ( e ? ( e . is_known ? String ( e . value ) : STRING ) : 0 ) ;
418407 break ;
408+ }
409+
419410 default :
420411 this . values . add ( UNKNOWN ) ;
421412 }
You can’t perform that action at this time.
0 commit comments