error in disjoint union refinement when accessing attribute via quotes, i.e. obj['attr']
- Dominant language
- Rust
- Stars
- 22.3k
- Forks
- 1.9k
- PR merge metrics
- No merged PRs in 30d
Description
here is the example from the docs:
```
// @flow
type Success = { success: true, value: boolean };
type Failed = { success: false, error: string };
type Response = Success | Failed;
function handleResponse(response: Response) {
if (response.success) {
var value: boolean = response.value; // Works!
} else {
var error: string = response.error; // Works!
}
}
```
it works. However if I try to access the attribute via quotes, not via dot notation, it breaks:
```
function handleResponse2(response: Response) {
if (response['success']) {
var value: boolean = response.value; // Works!
} else {
var error: string = response.error; // Works!
}
}
```
https://flow.org/try/#0PTAEAEDMBsHsHcBQAXAngBwKagMoFcBjAzAZxNAF5QBvUEw4sgLlGQCc9MAaUANwENonFgCNYsaJn4A7UAF8A3CgzYAYvwCWkgCahKNOg1IkWkQSW6hMbNrDYsS7DdIDm8pcqygASqXSxpC318ImNQAB9QdS1MbQ9IPGkCZA0A0AALGW1JXxJ-QMwACjY-AIsWXPyLAEoaRD0NSFBi0oKAOnpQslrqer0+fjYBoUxRcUkZfRK8ssw2gRGFUBBQAHU7AGsSAEI+uStoIN7+gaHrW3s6J1cp1os287sllfW2Ld29OUQvxEQEpJSaUy0mymEqswATC0ZgUKndMD0+o1mtMqpgANoAck6jBImIAuoiTgIhgthKAxBIpLIqKjZvNBJxnmBXu89gcjn09CSrDY7A5rm5afCHny2My1psdntvkA
Contributor guide
Assessment
This issue has not been assessed yet.