Uploaded image for project: 'Swift'
  1. Swift
  2. SR-2203

Implicit `self` doesn't work in initializer of lazy var

    Details

    • Type: Bug
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Compiler
    • Labels:
      None

      Description

      struct Foo {
        let bar: Int
        lazy var baz: Int = {
          return /* self. */bar
        }()
      }
      

      Does not work unless I add a `self`before 'bar'

        Attachments

          Issue Links

            Activity

            Hide
            jrose Jordan Rose added a comment -

            The whole model here is broken, and the current behavior is whatever happens to be implemented. We need to make sure we do the correct thing for both lazy and non-lazy vars.

            Show
            jrose Jordan Rose added a comment - The whole model here is broken, and the current behavior is whatever happens to be implemented. We need to make sure we do the correct thing for both lazy and non-lazy vars.
            Hide
            jpsim JP Simard added a comment -
            Show
            jpsim JP Simard added a comment - Fixed in https://github.com/apple/swift/pull/4676?
            Hide
            hagi Sebastian Hagedorn added a comment -

            Does this relate to/have an impact on https://bugs.swift.org/browse/SR-48 ?

            Show
            hagi Sebastian Hagedorn added a comment - Does this relate to/have an impact on https://bugs.swift.org/browse/SR-48 ?

              People

              • Assignee:
                Unassigned
                Reporter:
                harlan Harlan Haskins
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated: