lang: funcs: structs: Add some extra safety checks
Not sure if these are even needed.
This commit is contained in:
@@ -111,6 +111,16 @@ func (obj *ConstFunc) Stream(ctx context.Context) error {
|
||||
// Call this function with the input args and return the value if it is possible
|
||||
// to do so at this time.
|
||||
func (obj *ConstFunc) Call(ctx context.Context, args []types.Value) (types.Value, error) {
|
||||
if obj.Info() == nil {
|
||||
return nil, fmt.Errorf("info is empty")
|
||||
}
|
||||
if obj.Info().Sig == nil {
|
||||
return nil, fmt.Errorf("sig is empty")
|
||||
}
|
||||
if i, j := len(args), len(obj.Info().Sig.Ord); i != j {
|
||||
return nil, fmt.Errorf("arg length doesn't match, got %d, exp: %d", i, j)
|
||||
}
|
||||
|
||||
if obj.Value == nil {
|
||||
return nil, fmt.Errorf("no value available from const")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user