Skip to content
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

Cannot use inflight functions that take preflight class objects as parameters #7037

Open
Chriscbr opened this issue Aug 21, 2024 · 0 comments
Labels
🛠️ compiler Compiler ✨ enhancement New feature or request

Comments

@Chriscbr
Copy link
Contributor

Chriscbr commented Aug 21, 2024

Use Case

Currently it's not possible to write use functions that take preflight class objects as parameters, since accessing any fields or calling any methods on the object will result in a compilation error:

bring cloud;

let removePrefix = inflight (
  bucket: cloud.Bucket,
  prefix: str
) => {
  for key in bucket.list(prefix) {
    bucket.delete(key);
  }
};

As of writing the following errors are raised:

error: Expression of type "Bucket" references an unknown preflight object, can't qualify its capabilities
  --> wing/main.w:7:14
  |
7 |   for key in bucket.list(prefix) {
  |              ^^^^^^
  |
  = hint: Use a `lift` block to explicitly qualify the preflight object and disable this error
  = hint: For details see: https://www.winglang.io/docs/concepts/inflights#explicit-lift-qualification


error: Expression of type "Bucket" references an unknown preflight object, can't qualify its capabilities
  --> wing/main.w:8:5
  |
8 |     bucket.delete(key);
  |     ^^^^^^
  |
  = hint: Use a `lift` block to explicitly qualify the preflight object and disable this error
  = hint: For details see: https://www.winglang.io/docs/concepts/inflights#explicit-lift-qualification

The reason for these errors is that the lifting system used to automatically generate permissions does not track or calculate enough information to support these types of examples.

Related to #76

Proposed Solution

No response

Implementation Notes

No response

Component

Compiler

Community Notes

  • Please vote by adding a 👍 reaction to the issue to help us prioritize.
  • If you are interested to work on this issue, please leave a comment.
  • If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Discord.
@Chriscbr Chriscbr added ✨ enhancement New feature or request 🛠️ compiler Compiler labels Aug 21, 2024
@monadabot monadabot added this to Wing Aug 21, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New - not properly defined in Wing Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🛠️ compiler Compiler ✨ enhancement New feature or request
Projects
Status: 🆕 New - not properly defined
Development

No branches or pull requests

1 participant