Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mattnibs committed Jun 22, 2023
1 parent ad08b11 commit 8397c8d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 81 deletions.
10 changes: 0 additions & 10 deletions compiler/semantic/analyzer.go
Expand Up @@ -55,16 +55,6 @@ type opDecl struct {
scope *Scope // parent scope of op declaration.
}

func (a *analyzer) appendOpPath(op *dag.UserOp) error {
a.opPath = append(a.opPath, op)
for i := len(a.opPath) - 2; i >= 0; i-- {
if a.opPath[i] == op {
return opCycleError(a.opPath)
}
}
return nil
}

type opCycleError []*dag.UserOp

func (e opCycleError) Error() string {
Expand Down
8 changes: 3 additions & 5 deletions compiler/semantic/op.go
Expand Up @@ -1091,11 +1091,10 @@ func (a *analyzer) maybeConvertUserOp(call *ast.Call, seq dag.Seq) (dag.Op, erro
if a.opDecl != nil {
a.opDecl.deps = append(a.opDecl.deps, op)
} else {
// appendOpPath will return an error if the opDecl is already in the
// path, which means we have a cycle.
if err := a.appendOpPath(op); err != nil {
return nil, err
if slices.Contains(a.opPath, op) {
return nil, opCycleError(append(a.opPath, op))
}
a.opPath = append(a.opPath, op)
decl := a.opDeclMap[op]
oldscope := a.scope
a.scope = NewScope(decl.scope)
Expand All @@ -1112,7 +1111,6 @@ func (a *analyzer) maybeConvertUserOp(call *ast.Call, seq dag.Seq) (dag.Op, erro
return nil, err
}
}
// Else we need to
return &dag.UserOpCall{
Kind: "UserOpCall",
Name: call.Name,
Expand Down
61 changes: 0 additions & 61 deletions runtime/op/scope.go

This file was deleted.

10 changes: 5 additions & 5 deletions runtime/op/ztests/user-nested.yaml
Expand Up @@ -8,11 +8,11 @@ zed: |
op add4(x): (
add2(x) | add2(x)
)
add4(x)
add4(y)
input: '{x:1} {x:2} {x:3}'
input: '{y:1} {y:2} {y:3}'

output: |
{x:5}
{x:6}
{x:7}
{y:5}
{y:6}
{y:7}
10 changes: 10 additions & 0 deletions runtime/op/ztests/user-no-params.yaml
@@ -0,0 +1,10 @@
zed: |
op noparams(): (
yield "hello"
)
noparams()
input: "null"

output: |
"hello"

0 comments on commit 8397c8d

Please sign in to comment.