-
Notifications
You must be signed in to change notification settings - Fork 187
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
Empty list reaches unreachable!() #256
Comments
@g-r-a-n-t I was looking into this today. The general problem here is that we currently do not support the empty array expression |
This problem is basically identical to expression locations and I think we can handle it in a similar way. For example, say we have the expression During analysis, the parent node of an expression is responsible for making sure values are in their expected location. There are a few convenience functions to help parent nodes with this task. If the default location of the value is what we want, then we should analyze the expression using If there is a fe/compiler/src/yul/mappers/expressions.rs Lines 56 to 62 in fd9f78e
I think we could pretty much do the exact same thing here for type coercion (or casting, whatever we want to call it). So, we would start by adding a new attribute to pub struct ExpressionAttributes {
pub typ: Type,
pub location: Location,
pub move_location: Option<Location>,
pub coerced_type: Option<Type>,
} Then we would build into the analyzer a number of convenience functions for tacking coerced types onto expressions if possible. Then when our attributes are mapped by the compiler, we simply look at the required type conversion and wrap the expression inside of a call to a function that alters the values data and checks the validity of conversion (if needed). So, with regard to the specific problem mentioned here, the expression |
Another option might be to pass the expected type downward during analysis. (This would have to be an optional argument, since we won't always have an expected type.) The analysis of If we pass the expected type from the parent down to the child, the analysis of the child can just return the expected type in the case of an empty array. This also seems useful in cases like I don't know which method would work better in practice. Thinking about this a little more, maybe it would be useful to include an optional static value in the expression attributes, so cases like:
could be caught by the analyzer. |
Compiling this file:
On latest github master, built with
for fuzzing. Using https://github.com/agroce/afl-compiler-fuzzer + afl.rs.
The text was updated successfully, but these errors were encountered: