Given: `let x = Optional(3)` then
`let y = 5 + x ?? 2` will not compile
but 
`let y = 5 + (x ?? 2)` will.

Should NilCoalescingPrecedence be raised? The current operator precedence chain 
is:

BitwiseShiftPrecedence > MultiplicationPrecedence > AdditionPrecedence > 
RangeFormationPrecedence > CastingPrecedence > NilCoalescingPrecedence > 
ComparisonPrecedence > LogicalConjunctionPrecedence > 
LogicalDisjunctionPrecedence > TernaryPrecedence > AssignmentPrecedence > 
FunctionArrowPrecedence > [nothing]

It seems to me that `NilCoalescingPrecedence` should probably be higher than 
`MultiplicationPrecedence` and possibly higher `BitwiseShiftPrecedence` as its 
job is to produce an unwrapped value that can then be operated upon.

I think CastingPrecedence should be even higher because
`expression as? T ?? fallback value`
should be parsed as
`(expression as? T) ?? (fallback value)`

I apologize profusely because I know this is beyond last minute,

-- E

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to