Move LSP semantics into typed analysis

This commit is contained in:
pavel 2026-08-27 21:28:11 +02:00
commit bac1183593
26 changed files with 1232 additions and 637 deletions

View file

@ -33,7 +33,11 @@ func (checker *mutabilityChecker) checkFunction(function *FunctionDecl, class *C
_ = checker.scope.Define(&Symbol{Name: "this", Kind: VariableSymbol, Type: ClassType{Class: class}})
}
for _, param := range function.Params {
typ, _ := checker.semantic.ResolveType(param.Type)
typeParams := append([]string{}, function.TypeParams...)
if class != nil {
typeParams = append(class.TypeParams, typeParams...)
}
typ, _ := checker.semantic.ResolveTypeRefWithParams(param.TypeRef, typeParams)
_ = checker.scope.Define(&Symbol{Name: param.Name, Kind: VariableSymbol, Type: typ})
}
return checker.checkStmts(function.Body)
@ -46,7 +50,7 @@ func (checker *mutabilityChecker) checkStmts(statements []Stmt) error {
if err := checker.checkExpr(value.Value); err != nil {
return err
}
typ, _ := checker.semantic.ResolveType(value.Type)
typ, _ := checker.semantic.ResolveTypeRef(value.TypeRef)
_ = checker.scope.Define(&Symbol{Name: value.Name, Kind: VariableSymbol, Type: typ, Mutable: value.Mutable})
case MultiVarDecl:
if err := checker.checkExpr(value.Value); err != nil {
@ -214,7 +218,7 @@ func (checker *mutabilityChecker) checkExpr(expr Expr) error {
_ = checker.scope.Define(&Symbol{Name: "it", Kind: VariableSymbol, Type: UnknownType{}})
}
for _, param := range value.Params {
typ, _ := checker.semantic.ResolveType(param.Type)
typ, _ := checker.semantic.ResolveTypeRef(param.TypeRef)
_ = checker.scope.Define(&Symbol{Name: param.Name, Kind: VariableSymbol, Type: typ})
}
return checker.checkStmts(value.Body)