Files
swift-mirror/test/operators.swift
Doug Gregor 9fe42c0055 Merge infix precedence/associativity for binary operators, rather than
forcing one to declare, e.g., [infix_left=NNN] on every
declaration. The precedence/associativity will be merged from any
similarly-named operator in translation unit scope or in an imported
module. Fixes <rdar://problem/11261874> very, very narrowly for the
demo.

This implementation is hacky and slow; we'll replace it later with
<rdar://problem/11304699>.



Swift SVN r1570
2012-04-23 23:40:56 +00:00

18 lines
392 B
Swift

// RUN: %swift %s -verify
import swift
struct X { }
struct Y { }
func +(lhs : X, rhs : X) -> X { } // okay
func +++(lhs : X, rhs : X) -> X { } // expected-error{{binary operators must be declared 'infix_left'}}
func [infix_left=200] +(lhs : Y, rhs : Y) -> Y { } // FIXME: should error
func [infix_left=195] ++++(lhs : X, rhs : X) -> X { }
func ++++(lhs : Y, rhs : Y) -> Y { } // okay