Add expression functions with context boundaries
This commit is contained in:
parent
5085ae51aa
commit
773c34f3f4
18 changed files with 391 additions and 52 deletions
|
|
@ -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}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue