Skip to content

[SR-7862] Compiler incorrectly accepts throwing initialiser expression for a lazy property #50397

@hamishknight

Description

@hamishknight
Previous ID SR-7862
Radar rdar://problem/40773549
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
Target: x86_64-apple-darwin17.5.0

Apple Swift version 4.2-dev (LLVM 58850e66ae, Clang b58a7ad218, Swift feb3857)
Target: x86_64-apple-darwin17.5.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.2Regression, AcceptsInvalid
Assignee @hamishknight
Priority Medium

md5: 4273df80f79960ec355d543631d74ded

Issue Description:

The following all incorrectly compile on master (though two of them were correctly rejected in 4.1):

func foo() throws -> Int { return 0 }

class A {
  init() throws { }
  static func foo() throws -> Int { return 0 }
}

class B {
  // Incorrectly compiles on master, but correctly produces compiler error
  // "Call can throw, but errors cannot be thrown out of a property initializer"
  // in 4.1
  lazy var i = A.foo()

  // Incorrectly compiles on master, but correctly produces compiler error
  // "Call can throw, but errors cannot be thrown out of a property initializer"
  // in 4.1
  lazy var i1 = foo()

  // Incorrectly compiles in 4.1 and master
  lazy var i2 = A()
}

Metadata

Metadata

Assignees

Labels

accepts invalidBug: Accepts invalidbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfregressionswift 4.2

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions