mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
sema: accept an array literal of enum case references as compile-time constant
This commit is contained in:
20
test/Sema/const_enum_elements_array.swift
Normal file
20
test/Sema/const_enum_elements_array.swift
Normal file
@@ -0,0 +1,20 @@
|
||||
// RUN: %target-typecheck-verify-swift
|
||||
|
||||
enum E {
|
||||
case a
|
||||
case b
|
||||
|
||||
var z: E { .b }
|
||||
}
|
||||
|
||||
func getAE() -> E { return .a }
|
||||
|
||||
func test_without_const(_ : [E]) {}
|
||||
func testArr(_ : _const [E]) {}
|
||||
|
||||
testArr([])
|
||||
testArr([.a])
|
||||
testArr([.a, .b])
|
||||
|
||||
testArr([getAE()]) // expected-error {{expect a compile-time constant literal}}
|
||||
testArr([.a, .b, .a.z]) // expected-error {{expect a compile-time constant literal}}
|
||||
Reference in New Issue
Block a user