Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ go_repository(
# CEL Spec deps
go_repository(
name = "com_google_cel_spec",
commit = "a705ed2635bc198d8178880ff2fb8d3b8b10313d",
commit = "1a75e8893bb2a1b2f7a63a32a76eda50294837b2",
importpath = "github.com/google/cel-spec",
)

Expand Down
4 changes: 2 additions & 2 deletions common/types/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func (l *baseList) Equal(other ref.Val) ref.Val {
for i := IntZero; i < l.Size().(Int); i++ {
thisElem := l.Get(i)
otherElem := otherList.Get(i)
elemEq := thisElem.Equal(otherElem)
elemEq := Equal(thisElem, otherElem)
if elemEq == False {
return False
}
Expand Down Expand Up @@ -358,7 +358,7 @@ func (l *concatList) Equal(other ref.Val) ref.Val {
for i := IntZero; i < l.Size().(Int); i++ {
thisElem := l.Get(i)
otherElem := otherList.Get(i)
elemEq := thisElem.Equal(otherElem)
elemEq := Equal(thisElem, otherElem)
if elemEq == False {
return False
}
Expand Down
4 changes: 2 additions & 2 deletions common/types/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ func (m *baseMap) Equal(other ref.Val) ref.Val {
}
continue
}
valEq := thisVal.Equal(otherVal)
valEq := Equal(thisVal, otherVal)
if valEq == False {
return False
}
Expand Down Expand Up @@ -660,7 +660,7 @@ func (m *protoMap) Equal(other ref.Val) ref.Val {
retVal = MaybeNoSuchOverloadErr(otherVal)
return false
}
valEq := valVal.Equal(otherVal)
valEq := Equal(valVal, otherVal)
if valEq != True {
retVal = valEq
return false
Expand Down
10 changes: 10 additions & 0 deletions common/types/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,13 @@ func IsPrimitiveType(val ref.Val) bool {
}
return false
}

// Equal returns whether the two ref.Value are heterogeneously equivalent.
func Equal(lhs ref.Val, rhs ref.Val) ref.Val {
lNull := lhs == NullValue
rNull := rhs == NullValue
if lNull || rNull {
return Bool(lNull == rNull)
}
return lhs.Equal(rhs)
}
14 changes: 2 additions & 12 deletions interpreter/interpretable.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,12 +298,7 @@ func (eq *evalEq) ID() int64 {
func (eq *evalEq) Eval(ctx Activation) ref.Val {
lVal := eq.lhs.Eval(ctx)
rVal := eq.rhs.Eval(ctx)
lNull := lVal == types.NullValue
rNull := rVal == types.NullValue
if lNull || rNull {
return types.Bool(lNull == rNull)
}
return lVal.Equal(rVal)
return types.Equal(lVal, rVal)
}

// Cost implements the Coster interface method.
Expand Down Expand Up @@ -341,12 +336,7 @@ func (ne *evalNe) ID() int64 {
func (ne *evalNe) Eval(ctx Activation) ref.Val {
lVal := ne.lhs.Eval(ctx)
rVal := ne.rhs.Eval(ctx)
lNull := lVal == types.NullValue
rNull := rVal == types.NullValue
if lNull || rNull {
return types.Bool(lNull != rNull)
}
eqVal := lVal.Equal(rVal)
eqVal := types.Equal(lVal, rVal)
eqBool, ok := eqVal.(types.Bool)
if !ok {
return types.ValOrErr(eqVal, "no such overload: _!=_")
Expand Down