Skip to content

Commit 39e432b

Browse files
committed
fix: now Parse() returns *Expr instead of Value
1 parent 83cfb02 commit 39e432b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dsl/parse.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
// 1. Split to operation and its arguments
1414
// 2. Do semantic analysis recursively for its arguments
1515
// 3. Convert to *Expr
16-
func Parse(content []byte) (types.Value, error) {
16+
func Parse(content []byte) (*types.Expr, error) {
1717
var value interface{}
1818
if err := json.Unmarshal(content, value); err != nil {
1919
return nil, err
@@ -22,13 +22,14 @@ func Parse(content []byte) (types.Value, error) {
2222
if !ok {
2323
return nil, errors.New("top-level must be an array")
2424
}
25-
expr, err := parseArray(array)
25+
arrayValue, err := parseArray(array)
2626
if err != nil {
2727
return nil, err
2828
}
2929
// If expression's operator is a macro, return value may not be an array
3030
// (e.g. ["macro", 1, 2])
31-
if _, ok := expr.(*types.Expr); !ok {
31+
expr, ok := arrayValue.(*types.Expr)
32+
if !ok {
3233
return nil, errors.New("the result must be an expression")
3334
}
3435
return expr, nil

0 commit comments

Comments
 (0)