@@ -14,6 +14,15 @@ use sway_types::{integer_bits::IntegerBits, span::Span};
1414
1515pub ( super ) fn convert_literal_to_value ( context : & mut Context , ast_literal : & Literal ) -> Value {
1616 match ast_literal {
17+ // In Sway for now we don't have `as` casting and for integers which may be implicitly cast
18+ // between widths we just emit a warning, and essentially ignore it. We also assume a
19+ // 'Numeric' integer of undetermined width is 'u64`. The IR would like to be type
20+ // consistent and doesn't tolerate missing integers of different width, so for now, until we
21+ // do introduce explicit `as` casting, all integers are `u64` as far as the IR is
22+ // concerned.
23+ //
24+ // XXX The above isn't true for other targets. We need to improved this.
25+ // FIXME
1726 Literal :: U8 ( n) => ConstantContent :: get_uint ( context, 8 , * n as u64 ) ,
1827 Literal :: U16 ( n) => ConstantContent :: get_uint ( context, 64 , * n as u64 ) ,
1928 Literal :: U32 ( n) => ConstantContent :: get_uint ( context, 64 , * n as u64 ) ,
@@ -32,6 +41,7 @@ pub(super) fn convert_literal_to_constant(
3241 ast_literal : & Literal ,
3342) -> Constant {
3443 let c = match ast_literal {
44+ // All integers are `u64`. See comment above.
3545 Literal :: U8 ( n) => ConstantContent :: new_uint ( context, 8 , * n as u64 ) ,
3646 Literal :: U16 ( n) => ConstantContent :: new_uint ( context, 64 , * n as u64 ) ,
3747 Literal :: U32 ( n) => ConstantContent :: new_uint ( context, 64 , * n as u64 ) ,
0 commit comments