Open kr1sc opened 11 months ago
Description
Below code does not work.
enum TestEnum: CaseIterable { case one, two, three } extension TestEnum: RawRepresentable { init?(rawValue: Int) { guard rawValue >= 0 && rawValue < TestEnum.allCases.count else { return nil } self = TestEnum.allCases[rawValue] } var rawValue: Int { TestEnum.allCases.firstIndex(of: self)! } } TestEnum.one.rawValue
TestEnum.one.rawValue will cause recursive cascade of rawValue invocations resulting in EXC_BAD_ACCESS. For me it looks like invalid behavior.
TestEnum.one.rawValue
rawValue
EXC_BAD_ACCESS
Steps to reproduce
Run above code.
Expected behavior
TestEnum.one.rawValue correctly evaluates to value 0 in this case.
0
Environment
swift-driver version: 1.87.1 Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1) Target: arm64-apple-macosx14.0
Version 15.0 (15A240d)
iOS 17.0
Hi,kr1sc. Can I take the issue?.
Hi Aniket, I just report what I suspect is incorrect behavior, but I do not decide how it is handled or by whom.
Description
Below code does not work.
TestEnum.one.rawValue
will cause recursive cascade ofrawValue
invocations resulting inEXC_BAD_ACCESS
. For me it looks like invalid behavior.Steps to reproduce
Run above code.
Expected behavior
TestEnum.one.rawValue
correctly evaluates to value0
in this case.Environment