@@ -613,6 +613,8 @@ extension Expression {
613613 return
614614 }
615615 }
616+ case let . import( expression) :
617+ expression. inferTypes ( for: & params, in: context, with: . string)
616618 case let . infix( lhs, . step, rhs) :
617619 lhs. inferTypes ( for: & params, in: context, with: . range)
618620 rhs. inferTypes ( for: & params, in: context, with: . number)
@@ -746,6 +748,23 @@ extension Expression {
746748 case let . member( expression, member) :
747749 let type = try expression. staticType ( in: context)
748750 return type. memberType ( member. name) ?? . any
751+ case let . import( expression) :
752+ var file : String ?
753+ switch expression. type {
754+ case let . string( string) :
755+ file = string
756+ case let . tuple( expressions) :
757+ if case let . string( string) ? = expressions. last? . type {
758+ file = string
759+ }
760+ default :
761+ break
762+ }
763+ switch file? . components ( separatedBy: " . " ) . last? . lowercased ( ) ?? " " {
764+ case " txt " : return . string
765+ case " shape " , " json " , " " : return . any
766+ default : return . mesh
767+ }
749768 }
750769 }
751770}
@@ -856,8 +875,6 @@ extension Statement {
856875 caseStatement. inferTypes ( for: & params, in: context, with: type)
857876 }
858877 elseBody? . inferTypes ( for: & params, in: context)
859- case let . import( expression) :
860- expression. inferTypes ( for: & params, in: context, with: . string)
861878 case . option:
862879 return
863880 }
@@ -946,23 +963,6 @@ extension Statement {
946963 }
947964 }
948965 return type
949- case let . import( expression) :
950- var file : String ?
951- switch expression. type {
952- case let . string( string) :
953- file = string
954- case let . tuple( expressions) :
955- if case let . string( string) ? = expressions. last? . type {
956- file = string
957- }
958- default :
959- break
960- }
961- switch file? . components ( separatedBy: " . " ) . last? . lowercased ( ) ?? " " {
962- case " txt " : return . string
963- case " shape " , " json " , " " : return . any
964- default : return . mesh
965- }
966966 }
967967 }
968968}
@@ -976,7 +976,7 @@ extension Array where Element == Statement {
976976 let type = ( try ? definition. staticType ( in: context) ) ?? . any
977977 context. define ( identifier. name, as: . placeholder( type) )
978978 }
979- case . command, . option, . forloop, . ifelse, . switchcase, . expression, . import :
979+ case . command, . option, . forloop, . ifelse, . switchcase, . expression:
980980 break
981981 }
982982 }
0 commit comments