mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-11 06:23:39 +00:00
compiler: implement comparing channel values
This commit is contained in:
committed by
Ron Evans
parent
c981f14e61
commit
0a40219680
@@ -1953,10 +1953,12 @@ func (c *Compiler) parseBinOp(op token.Token, typ types.Type, x, y llvm.Value, p
|
||||
default:
|
||||
return llvm.Value{}, c.makeError(pos, "binop on interface: "+op.String())
|
||||
}
|
||||
case *types.Map, *types.Pointer:
|
||||
case *types.Chan, *types.Map, *types.Pointer:
|
||||
// Maps are in general not comparable, but can be compared against nil
|
||||
// (which is a nil pointer). This means they can be trivially compared
|
||||
// by treating them as a pointer.
|
||||
// Channels behave as pointers in that they are equal as long as they
|
||||
// are created with the same call to make or if both are nil.
|
||||
switch op {
|
||||
case token.EQL: // ==
|
||||
return c.builder.CreateICmp(llvm.IntEQ, x, y, ""), nil
|
||||
|
||||
Reference in New Issue
Block a user