mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
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
18 lines
392 B
Swift
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
|
|
|
|
|