Skip to content

Commit

Permalink
Fix ride func scope (#391)
Browse files Browse the repository at this point in the history
* Incorrect level of a function call arguments evaluation fixed. Tests added.

* Missed AssetInfoV4 field added.
  • Loading branch information
alexeykiselev authored Nov 25, 2020
1 parent aacba70 commit b0ff654
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/ride/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func fullAssetInfoToObject(info *proto.FullAssetInfo) rideObject {
obj := assetInfoToObject(&info.AssetInfo)
obj["name"] = rideString(info.Name)
obj["description"] = rideString(info.Description)
obj["minSponsoredFee"] = rideInt(info.SponsorshipCost)
return obj
}

Expand Down
171 changes: 171 additions & 0 deletions pkg/ride/tree_evaluation_test.go

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pkg/ride/tree_evaluator.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,6 @@ func (e *treeEvaluator) walk(node Node) (rideType, error) {
if len(n.Arguments) != len(uf.Arguments) {
return nil, errors.Errorf("mismatched arguments number of user function '%s'", id)
}
var tmp int
tmp, e.s.cl = e.s.cl, cl
args := make([]esValue, len(n.Arguments))
for i, arg := range n.Arguments {
an := uf.Arguments[i]
Expand All @@ -384,6 +382,8 @@ func (e *treeEvaluator) walk(node Node) (rideType, error) {
for i, arg := range args {
e.s.cs[len(e.s.cs)-1][i] = arg
}
var tmp int
tmp, e.s.cl = e.s.cl, cl
r, err := e.walk(uf.Body)
if err != nil {
return nil, errors.Wrapf(err, "failed to evaluate function '%s' body", id)
Expand Down

0 comments on commit b0ff654

Please sign in to comment.