mirror of
https://github.com/apple/swift.git
synced 2026-06-20 15:42:51 +02:00
0bbd35242c
This change adds an experimental feature 'LiteralExpressions` which allows for use of simple binary expressions of integer type composed of literal value operands. For now, such literal expressions are only supported in initializers of '@section` values.
14 lines
484 B
Swift
14 lines
484 B
Swift
// Constant globals rejected for not being constant values
|
|
// REQUIRES: swift_feature_CompileTimeValues
|
|
// RUN: %target-swift-frontend -emit-ir -primary-file %s -parse-as-library -verify -enable-experimental-feature CompileTimeValues
|
|
|
|
@const let a: Bool = Bool.random()
|
|
// expected-error@-1 {{not supported in a literal expression}}
|
|
|
|
func foo() -> Int {
|
|
return 42 * Int.random(in: 0 ..< 10)
|
|
}
|
|
|
|
@const let b: Int = foo()
|
|
// expected-error@-1 {{not supported in a literal expression}}
|