Skip to content

Option to disable short-circuiting #831

@lvliangxiong

Description

@lvliangxiong
package main

import (
	"fmt"

	"github.com/antonmedv/expr"
)

func main() {
	env := map[string]any{
		"a": func() bool { fmt.Println("a executed"); return true },
		"b": func() bool { fmt.Println("b executed"); return false },
	}

	program, _ := expr.Compile(`a() || b()`, expr.Env(env))

	_, _ = expr.Run(program, env)
	// Output:
	// a executed
}

Output of above code will be a executed.
But I'm wondering if there's an option which I can pass to the expr, or something else I'can do to disable the shortcircuit effect.
After disabling shortcircuit, output will be a executed and b executed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions