Files
swift-mirror/test/ConstValues/DiagNotConstSyntactic.swift
T
Artem Chikin 0bbd35242c [Literal Expressions] Add support for simple constant-folded literal expressions
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.
2026-02-09 11:35:45 +00:00

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}}