@@ -135,32 +135,32 @@ type CheckResult struct {
135135 Program parser.Program
136136
137137 stmtType Type
138- ExprTypes map [parser.ValueExpr ]Type
139- VarTypes map [parser.VarDeclaration ]Type
138+ exprTypes map [parser.ValueExpr ]Type
139+ varTypes map [parser.VarDeclaration ]Type
140140}
141141
142- func (r * CheckResult ) getExprType (expr parser.ValueExpr ) Type {
143- exprType , ok := r .ExprTypes [expr ]
142+ func (r * CheckResult ) GetExprType (expr parser.ValueExpr ) Type {
143+ exprType , ok := r .exprTypes [expr ]
144144 if ! ok {
145145 t := TVar {}
146- r .ExprTypes [expr ] = & t
146+ r .exprTypes [expr ] = & t
147147 return & t
148148 }
149- return exprType
149+ return exprType . Resolve ()
150150}
151151
152- func (r * CheckResult ) getVarDeclType (decl parser.VarDeclaration ) Type {
153- exprType , ok := r .VarTypes [decl ]
152+ func (r * CheckResult ) GetVarDeclType (decl parser.VarDeclaration ) Type {
153+ exprType , ok := r .varTypes [decl ]
154154 if ! ok {
155155 t := TVar {}
156- r .VarTypes [decl ] = & t
156+ r .varTypes [decl ] = & t
157157 return & t
158158 }
159- return exprType
159+ return exprType . Resolve ()
160160}
161161
162162func (r * CheckResult ) unifyNodeWith (expr parser.ValueExpr , t Type ) {
163- exprT := r .getExprType (expr )
163+ exprT := r .GetExprType (expr )
164164 r .unify (expr .GetRange (), exprT , t )
165165}
166166
@@ -224,8 +224,8 @@ func newCheckResult(program parser.Program) CheckResult {
224224 unusedVars : make (map [string ]parser.Range ),
225225 varResolution : make (map [* parser.Variable ]parser.VarDeclaration ),
226226 fnCallResolution : make (map [* parser.FnCallIdentifier ]FnCallResolution ),
227- ExprTypes : make (map [parser.ValueExpr ]Type ),
228- VarTypes : make (map [parser.VarDeclaration ]Type ),
227+ exprTypes : make (map [parser.ValueExpr ]Type ),
228+ varTypes : make (map [parser.VarDeclaration ]Type ),
229229 }
230230}
231231
@@ -242,7 +242,7 @@ func (res *CheckResult) check() {
242242
243243 if varDecl .Origin != nil {
244244 res .checkExpression (* varDecl .Origin , varDecl .Type .Name )
245- res .unifyNodeWith (* varDecl .Origin , res .getVarDeclType (varDecl ))
245+ res .unifyNodeWith (* varDecl .Origin , res .GetVarDeclType (varDecl ))
246246 }
247247 }
248248 }
@@ -357,10 +357,10 @@ func (res *CheckResult) checkFnCallArity(fnCall *parser.FnCall) {
357357 case FnVarOriginBalance , FnVarOriginOverdraft :
358358 // we run unify(<expr>, <asset>) in:
359359 // <expr> := balance(@acc, <asset>)
360- res .unifyNodeWith (fnCall , res .getExprType (validArgs [1 ]))
360+ res .unifyNodeWith (fnCall , res .GetExprType (validArgs [1 ]))
361361
362362 case FnVarOriginGetAsset :
363- res .unifyNodeWith (fnCall , res .getExprType (validArgs [0 ]))
363+ res .unifyNodeWith (fnCall , res .GetExprType (validArgs [0 ]))
364364 }
365365 } else {
366366 for _ , arg := range validArgs {
@@ -421,7 +421,7 @@ func (res *CheckResult) checkTypeOf(lit parser.ValueExpr, typeHint string) strin
421421 case * parser.Variable :
422422 if varDeclaration , ok := res .DeclaredVars [lit .Name ]; ok {
423423 res .varResolution [lit ] = varDeclaration
424- res .unifyNodeWith (lit , res .getVarDeclType (varDeclaration ))
424+ res .unifyNodeWith (lit , res .GetVarDeclType (varDeclaration ))
425425 } else {
426426 res .pushDiagnostic (lit .Range , UnboundVariable {Name : lit .Name , Type : typeHint })
427427 }
@@ -440,11 +440,11 @@ func (res *CheckResult) checkTypeOf(lit parser.ValueExpr, typeHint string) strin
440440 we unify $mon and $asset in:
441441 `let $mon := [$asset 42]`
442442 */
443- res .unifyNodeWith (lit , res .getExprType (lit .Asset ))
443+ res .unifyNodeWith (lit , res .GetExprType (lit .Asset ))
444444 return TypeMonetary
445445
446446 case * parser.BinaryInfix :
447- res .unifyNodeWith (lit .Left , res .getExprType (lit .Right ))
447+ res .unifyNodeWith (lit .Left , res .GetExprType (lit .Right ))
448448
449449 switch lit .Operator {
450450 case parser .InfixOperatorPlus :
0 commit comments