Add expression functions with context boundaries

This commit is contained in:
pavel 2026-08-27 23:05:49 +02:00
commit 773c34f3f4
18 changed files with 391 additions and 52 deletions

View file

@ -188,6 +188,11 @@ func analyzeProgram(program *Program, additional []*Program, metadata []*Package
if err != nil {
return nil, fmt.Errorf("function %s: %w", decl.Name, err)
}
if decl.InferReturn {
function := typ.(FunctionType)
function.Result = UnknownType{}
typ = function
}
if err := semantic.Global.Define(&Symbol{Name: decl.Name, Kind: FunctionSymbolKind, Type: typ, Decl: decl}); err != nil {
return nil, err
}
@ -215,6 +220,11 @@ func analyzeProgram(program *Program, additional []*Program, metadata []*Package
if err != nil {
return nil, fmt.Errorf("method %s.%s: %w", decl.Name, method.Name, err)
}
if method.InferReturn {
function := typ.(FunctionType)
function.Result = UnknownType{}
typ = function
}
class.Methods[method.Name] = &Symbol{Name: method.Name, Kind: FunctionSymbolKind, Type: typ, Decl: method}
}
}