Skip to content

Property wrapper on local variable cannot be used with its projected value in ExprPattern #66561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hamishknight opened this issue Jun 12, 2023 · 0 comments · Fixed by #66565
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. patterns Feature: patterns type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Contributor

hamishknight commented Jun 12, 2023

This fails to compile:

@propertyWrapper
struct WrapperValue<Value> {
  var value: Value
  init(wrappedValue: Value) {
    self.value = wrappedValue
  }

  var projectedValue: Self {
    return self
  }

  var wrappedValue: Value {
    get {
      self.value
    }
    set {
      self.value = newValue
    }
  }
}

func test() {
  let _ = {
    @WrapperValue var value: Bool = false
    switch value {
    case $value.wrappedValue:
      break
    default:
      break
    }
  }
}

But ought to.

rdar://110649179

@hamishknight hamishknight added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. type checker Area → compiler: Semantic analysis patterns Feature: patterns labels Jun 12, 2023
@hamishknight hamishknight self-assigned this Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. patterns Feature: patterns type checker Area → compiler: Semantic analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant