Enum case value must be literal: is there a macro that does literal expression evaluation and fill in the case value?

Note that compiler already rejects this code when "func -" is defined as a standalone function:

func -(lhs: Double, rhs: Double) -> Double {
    Double.random(in: 0...1)
}

1.0 - 2.0 // 🛑 Error: Ambiguous use of operator '-'

Whether that the compiler does not reject this code (or complain otherwise) when "func -" is defined as a static function defined in an extension of Double is a bug or a feature – I don't know.

2 Likes