mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Syntactically verify that initializer expressions of '@const' variables and argument expressions to '@const' parameters consist strictly of syntactically-verifiable set of basic values and operations
19 lines
648 B
Swift
19 lines
648 B
Swift
// Constant globals on simple integer literals
|
|
// REQUIRES: swift_feature_CompileTimeValues
|
|
// REQUIRES: swift_feature_CompileTimeValuesPreview
|
|
// RUN: %target-swift-frontend -emit-sil -primary-file %s -verify -enable-experimental-feature CompileTimeValues -enable-experimental-feature CompileTimeValuesPreview
|
|
|
|
func bar(@const _ thing: UInt) -> UInt {
|
|
return thing
|
|
}
|
|
|
|
func foo() {
|
|
let _ = bar(42)
|
|
let _ = bar(0xf000f000)
|
|
#if _pointerBitWidth(_64)
|
|
let _ = bar(0xf000f000_f000f000)
|
|
#endif
|
|
let _ = bar(UInt.random(in: 0..<10))
|
|
// expected-error@-1 {{expected a compile-time value argument for a '@const' parameter}}
|
|
}
|