Skip to content

Commit

Permalink
pass interpreter, location range and separator to Split function
Browse files Browse the repository at this point in the history
  • Loading branch information
darkdrag00nv2 committed Sep 21, 2023
1 parent cd2d26c commit 839556c
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions runtime/interpreter/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,12 @@ func (v *StringValue) GetMember(interpreter *Interpreter, locationRange Location
interpreter,
sema.StringTypeSplitFunctionType,
func(invocation Invocation) Value {
return v.Split(invocation)
separator, ok := invocation.Arguments[0].(*StringValue)
if !ok {
panic(errors.NewUnreachableError())

Check warning on line 1355 in runtime/interpreter/value.go

View check run for this annotation

Codecov / codecov/patch

runtime/interpreter/value.go#L1355

Added line #L1355 was not covered by tests
}

return v.Split(invocation.Interpreter, invocation.LocationRange, separator.Str)
},
)
}
Expand Down Expand Up @@ -1407,15 +1412,8 @@ func (v *StringValue) ToLower(interpreter *Interpreter) *StringValue {
)
}

func (v *StringValue) Split(invocation Invocation) Value {
inter := invocation.Interpreter

separator, ok := invocation.Arguments[0].(*StringValue)
if !ok {
panic(errors.NewUnreachableError())
}

split := strings.Split(v.Str, separator.Str)
func (v *StringValue) Split(inter *Interpreter, locationRange LocationRange, separator string) Value {
split := strings.Split(v.Str, separator)

var index int
count := len(split)
Expand Down Expand Up @@ -1443,7 +1441,7 @@ func (v *StringValue) Split(invocation Invocation) Value {

value := strValue.Transfer(
inter,
invocation.LocationRange,
locationRange,
atree.Address{},
true,
nil,
Expand Down

0 comments on commit 839556c

Please sign in to comment.