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

Type checking a mapping/listing should be lazy #406

Open
bioball opened this issue Apr 5, 2024 · 2 comments
Open

Type checking a mapping/listing should be lazy #406

bioball opened this issue Apr 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@bioball
Copy link
Contributor

bioball commented Apr 5, 2024

Currently, accessing a property of type Mapping<TypeA, TypeB> or Listing<Type> will shallow-force the whole mapping/listing. The shallow-force gets skipped if the type is unknown or Any (e.g. Listing, or Listing<unknown>, or Listing<Any>).

This should not throw, but does currently:

hidden nums: Listing<Int> = new {
  throw("uh oh")
  1
}

result = nums[1]

This is related to #405

@bioball bioball added the bug Something isn't working label Apr 5, 2024
@harryjackson
Copy link

This is just another example. The addition happens and we get 33 but at what point is the type checking meant to happen. Using the IntelliJ plugin I get warnings telling me I'm doing something stupid.

foo = new Listing<YamlRenderer> {
  11
}

bar = new Listing<String> {
  22
}

output {
  value = foo[0] + bar[0]
  renderer = new YamlRenderer{}
}

output

33

@bioball
Copy link
Contributor Author

bioball commented Apr 7, 2024

@harryjackson: what you're seeing is the #405 bug, rather than this one. To fix, you should add a type annotation to your properties:

foo: Listing<YamlRenderer> = new {
  11
}

bar: Listing<String> = new {
  22
}

output {
  value = foo[0] + bar[0]
  renderer = new YamlRenderer{}
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants