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

Reduce propagation of error values #1122

Open
degory opened this issue Mar 17, 2024 · 0 comments
Open

Reduce propagation of error values #1122

degory opened this issue Mar 17, 2024 · 0 comments

Comments

@degory
Copy link
Owner

degory commented Mar 17, 2024

When there's an error in an expression, such as referencing an undefined symbol or when no matching overload is found for a function call, an error value is produced at the point the error is detected and reported. These error values then propagate and suppress further errors when consumed, to prevent cascades of spurious subsequent errors.

Usually, if any input to a sub-expression is an error value, then the output will also be an error value. This is good for suppressing subsequent spurious errors, but it can reduce the information available to the language extension. For example, it means that variable types can be inferred to be !!! (error), or function call overloads do not resolve, which in turn breaks hover or navigate to definition features.

In some cases, we can stop the propagation of error values if the result of a sub-expression, involving one or more error values, is nevertheless unambiguously typed. For example, we may still find a reasonable operator or function overload match even if one of the operands or some of the arguments are error values.

This approach is safe, even if we actually pick an incorrect overload, because there will always have been a prior error message issued at the point of origin for any error value. That error message will prevent the compiler from producing executable output. In other words, in the worst-case scenario, we could offer misleading information to the user through the language extension, but we will not generate incorrect code.

degory added a commit that referenced this issue Mar 17, 2024
Enhancements:
- Add initial support for recursion in anonymous functions (see #1068)
Reduce propagation of error values (see #1122)

Technical:
- Report consumption of error or any typed values as hints for diagnostic purposes
- Track whether any error or any values consumed, for future use detecting potentially unreported type inference failures
degory added a commit that referenced this issue Mar 18, 2024
Enhancements:
- Add initial support for recursion in anonymous functions (see #1068)
- Reduce propagation of error values (see #1122)

Technical:
- Report consumption of error or any typed values as hints for diagnostic purposes
- Track whether any error or any values consumed, for future use detecting potentially unreported type inference failures
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant