Files
swift-mirror/test/decl/init/let-mutability.swift
Doug Gregor d051b62676 Ensure that we do not turn rvalues into lvalues
The computation that determined whether an access to a `let` instance
property within a constructor should be an initialization conflated the
cases of "we don't have a base expression" and "the base expression is
not something that could be `self`", and incorrectly identified rvalue
bases as being "initializable". Make the interface properly separate
out these cases, so we don't turn an lvalue into an rvalue access.

Fixes rdar://128661833.
2024-05-24 18:22:04 -07:00

23 lines
556 B
Swift

// RUN: %target-swift-frontend -typecheck -dump-ast %s | %FileCheck %s
public struct Data {
init(_ bytes: [UInt8]) { }
}
internal struct Item {
public let data: Data
public init(tag: UInt8) {
self.data = Data([tag << 2])
}
// CHECK-LABEL: constructor_decl{{.*}}"init(tag:value:)"
public init(tag: UInt8, value: UInt) {
// CHECK: assign_expr
// CHECK: member_ref_expr type="@lvalue Data"
// CHECK-NEXT: declref_expr type="@lvalue Item"
// CHECK-NEXT: member_ref_expr type="Data"
self.data = Self(tag: tag).data
}
}