Parser - Cast
Refactor code to use the new parse_type method. We pass false to `parse_type` indicating that we do not accept `x as pub u8` for example, atleast for now
@@ -18,7 +18,17 @@ impl CastParser {
Ok(ExpressionKind::Cast(Box::new(CastExpression {
lhs,
- r#type: parser.parse_type()?,
+ // `x as pub u8` is not supported. If we move away from `pub, priv and const` declarations
+ // then it would make sense to have it.
+ // It would then look like : `let z = x as pub u8`
+ //
+ // XXX: We could check for base types here, however in the future it would be nice
+ // to be able to convert between array types.
+ //
+ // An example is that if we have [4]u32 we can use `as` to convert it to a [4]u8
+ // let x = [a,b,c,d]
+ // let z = x as [4]u8
+ r#type: parser.parse_type(false)?,
})))
}
}
