diff --git a/CHANGELOG.md b/CHANGELOG.md index feb9cf1c..40065c33 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,9 @@ - **aiken**: Summary should always print at the end of the output not just when checks plus warnings is greater than zero. @rvcas +- **aiken-lang**: Fix comments not being able to occur in ByteArray array + members. @rvcas + ## v1.1.14 - 2025-03-21 ### Added diff --git a/crates/aiken-lang/src/ast.rs b/crates/aiken-lang/src/ast.rs index 853ce13d..c0d0e471 100644 --- a/crates/aiken-lang/src/ast.rs +++ b/crates/aiken-lang/src/ast.rs @@ -1535,8 +1535,8 @@ impl BinOp { } } -pub type UntypedPattern = Pattern<(), (), Namespace>; -pub type TypedPattern = Pattern, String>; +pub type UntypedPattern = Pattern<(), (), Namespace, (u8, Span)>; +pub type TypedPattern = Pattern, String, u8>; impl TypedPattern { pub fn var(name: &str) -> Self { @@ -1660,7 +1660,7 @@ pub enum Namespace { } #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] -pub enum Pattern { +pub enum Pattern { Int { location: Span, value: String, @@ -1669,7 +1669,7 @@ pub enum Pattern { ByteArray { location: Span, - value: Vec, + value: Vec, preferred_format: ByteArrayFormatPreference, }, @@ -1731,7 +1731,7 @@ pub enum Pattern { }, } -impl Pattern { +impl Pattern { pub fn location(&self) -> Span { match self { Pattern::Assign { pattern, .. } => pattern.location(), @@ -2207,11 +2207,11 @@ impl AssignmentKind { } } -pub type MultiPattern = - Vec>; +pub type MultiPattern = + Vec>; -pub type UntypedMultiPattern = MultiPattern<(), (), Namespace>; -pub type TypedMultiPattern = MultiPattern, String>; +pub type UntypedMultiPattern = MultiPattern<(), (), Namespace, (u8, Span)>; +pub type TypedMultiPattern = MultiPattern, String, u8>; #[derive(Debug, Clone, PartialEq)] pub struct UntypedClause { diff --git a/crates/aiken-lang/src/expr.rs b/crates/aiken-lang/src/expr.rs index 35d9ba83..4f5264e2 100644 --- a/crates/aiken-lang/src/expr.rs +++ b/crates/aiken-lang/src/expr.rs @@ -649,7 +649,7 @@ pub enum UntypedExpr { ByteArray { location: Span, - bytes: Vec, + bytes: Vec<(u8, Span)>, preferred_format: ByteArrayFormatPreference, }, @@ -977,7 +977,7 @@ impl UntypedExpr { location: Span::empty(), value: UntypedExpr::ByteArray { location: Span::empty(), - bytes, + bytes: bytes.into_iter().map(|b| (b, Span::empty())).collect(), preferred_format: ByteArrayFormatPreference::HexadecimalString, }, }], @@ -1001,11 +1001,15 @@ impl UntypedExpr { value: from_pallas_bigint(i).to_string(), }, - PlutusData::BoundedBytes(bytes) => UntypedExpr::ByteArray { - location: Span::empty(), - bytes: bytes.into(), - preferred_format: ByteArrayFormatPreference::HexadecimalString, - }, + PlutusData::BoundedBytes(bytes) => { + let bytes: Vec = bytes.into(); + + UntypedExpr::ByteArray { + location: Span::empty(), + bytes: bytes.into_iter().map(|b| (b, Span::empty())).collect(), + preferred_format: ByteArrayFormatPreference::HexadecimalString, + } + } PlutusData::Array(elems) => UntypedExpr::List { location: Span::empty(), @@ -1113,9 +1117,10 @@ impl UntypedExpr { value: String::from_utf8(bytes.to_vec()).expect("invalid UTF-8 string"), }) } else { + let bytes: Vec = bytes.into(); Ok(UntypedExpr::ByteArray { location: Span::empty(), - bytes: bytes.into(), + bytes: bytes.into_iter().map(|b| (b, Span::empty())).collect(), preferred_format: ByteArrayFormatPreference::HexadecimalString, }) } diff --git a/crates/aiken-lang/src/format.rs b/crates/aiken-lang/src/format.rs index eddb252a..ecc5af2d 100644 --- a/crates/aiken-lang/src/format.rs +++ b/crates/aiken-lang/src/format.rs @@ -372,13 +372,24 @@ impl<'comments> Formatter<'comments> { bytes, preferred_format, .. - } => self.bytearray(bytes, None, preferred_format), + } => self.bytearray( + &bytes + .iter() + .map(|b| (*b, Span::empty())) + .collect::>(), + None, + preferred_format, + ), TypedExpr::CurvePoint { point, preferred_format, .. } => self.bytearray( - &point.compress(), + &point + .compress() + .into_iter() + .map(|b| (b, Span::empty())) + .collect::>(), Some(point.as_ref().into()), preferred_format, ), @@ -895,7 +906,7 @@ impl<'comments> Formatter<'comments> { pub fn bytearray<'a>( &mut self, - bytes: &[u8], + bytes: &[(u8, Span)], curve: Option, preferred_format: &ByteArrayFormatPreference, ) -> Document<'a> { @@ -906,7 +917,9 @@ impl<'comments> Formatter<'comments> { curve.map(|c| c.to_string()).unwrap_or_default(), )) .append("\"") - .append(Document::String(hex::encode(bytes))) + .append(Document::String(hex::encode( + bytes.iter().map(|(b, _)| *b).collect::>(), + ))) .append("\""), ByteArrayFormatPreference::ArrayOfBytes(Base::Decimal { .. }) => "#" .to_doc() @@ -914,8 +927,19 @@ impl<'comments> Formatter<'comments> { curve.map(|c| c.to_string()).unwrap_or_default(), )) .append( - flex_break("[", "[") - .append(join(bytes.iter().map(|b| b.to_doc()), break_(",", ", "))) + break_("[", "[") + .append(join( + bytes.iter().map(|b| { + let doc = b.0.to_doc(); + + if b.1 == Span::empty() { + doc + } else { + commented(doc, self.pop_comments(b.1.start)) + } + }), + break_(",", ", "), + )) .nest(INDENT) .append(break_(",", "")) .append("]"), @@ -927,14 +951,20 @@ impl<'comments> Formatter<'comments> { curve.map(|c| c.to_string()).unwrap_or_default(), )) .append( - flex_break("[", "[") + break_("[", "[") .append(join( bytes.iter().map(|b| { - Document::String(if *b < 16 { - format!("0x0{b:x}") + let doc = Document::String(if b.0 < 16 { + format!("0x0{:x}", b.0) } else { - format!("{b:#x}") - }) + format!("{:#x}", b.0) + }); + + if b.1 == Span::empty() { + doc + } else { + commented(doc, self.pop_comments(b.1.start)) + } }), break_(",", ", "), )) @@ -946,7 +976,8 @@ impl<'comments> Formatter<'comments> { ByteArrayFormatPreference::Utf8String => nil() .append("\"") .append(Document::String(escape( - core::str::from_utf8(bytes).unwrap(), + core::str::from_utf8(&bytes.iter().map(|(b, _)| *b).collect::>()) + .unwrap(), ))) .append("\""), } @@ -1007,7 +1038,11 @@ impl<'comments> Formatter<'comments> { preferred_format, .. } => self.bytearray( - &point.compress(), + &point + .compress() + .into_iter() + .map(|b| (b, Span::empty())) + .collect::>(), Some(point.as_ref().into()), preferred_format, ), diff --git a/crates/aiken-lang/src/parser/expr/bytearray.rs b/crates/aiken-lang/src/parser/expr/bytearray.rs index d5f5ce29..8b7b9e02 100644 --- a/crates/aiken-lang/src/parser/expr/bytearray.rs +++ b/crates/aiken-lang/src/parser/expr/bytearray.rs @@ -11,12 +11,14 @@ pub fn parser() -> impl Parser { |bytes, preferred_format, curve, location, emit| match curve { Some(curve @ ast::CurveType::Bls12_381(point)) => { let point = match point { - ast::Bls12_381PointType::G1 => { - blst::blst_p1::uncompress(&bytes).map(ast::Bls12_381Point::G1) - } - ast::Bls12_381PointType::G2 => { - blst::blst_p2::uncompress(&bytes).map(ast::Bls12_381Point::G2) - } + ast::Bls12_381PointType::G1 => blst::blst_p1::uncompress( + &bytes.iter().map(|&(byte, _)| byte).collect::>(), + ) + .map(ast::Bls12_381Point::G1), + ast::Bls12_381PointType::G2 => blst::blst_p2::uncompress( + &bytes.iter().map(|&(byte, _)| byte).collect::>(), + ) + .map(ast::Bls12_381Point::G2), }; let point = point.unwrap_or_else(|_err| { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/bytearray_base16.snap b/crates/aiken-lang/src/parser/expr/snapshots/bytearray_base16.snap index 36d36a2a..e779f24a 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/bytearray_base16.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/bytearray_base16.snap @@ -5,9 +5,18 @@ description: "Code:\n\n#\"00aaff\"" ByteArray { location: 0..9, bytes: [ - 0, - 170, - 255, + ( + 0, + 0..0, + ), + ( + 170, + 0..0, + ), + ( + 255, + 0..0, + ), ], preferred_format: HexadecimalString, } diff --git a/crates/aiken-lang/src/parser/expr/snapshots/bytearray_basic.snap b/crates/aiken-lang/src/parser/expr/snapshots/bytearray_basic.snap index 58c6b407..8ca0f30a 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/bytearray_basic.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/bytearray_basic.snap @@ -5,9 +5,18 @@ description: "Code:\n\n#[0, 170, 255]" ByteArray { location: 0..14, bytes: [ - 0, - 170, - 255, + ( + 0, + 2..3, + ), + ( + 170, + 5..8, + ), + ( + 255, + 10..13, + ), ], preferred_format: ArrayOfBytes( Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/bytearray_utf8_encoded.snap b/crates/aiken-lang/src/parser/expr/snapshots/bytearray_utf8_encoded.snap index 611eefcf..2fe656f6 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/bytearray_utf8_encoded.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/bytearray_utf8_encoded.snap @@ -5,11 +5,26 @@ description: "Code:\n\n\"aiken\"" ByteArray { location: 0..7, bytes: [ - 97, - 105, - 107, - 101, - 110, + ( + 97, + 0..0, + ), + ( + 105, + 0..0, + ), + ( + 107, + 0..0, + ), + ( + 101, + 0..0, + ), + ( + 110, + 0..0, + ), ], preferred_format: Utf8String, } diff --git a/crates/aiken-lang/src/parser/expr/snapshots/bytearray_utf8_escaped.snap b/crates/aiken-lang/src/parser/expr/snapshots/bytearray_utf8_escaped.snap index 1f385b21..96350718 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/bytearray_utf8_escaped.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/bytearray_utf8_escaped.snap @@ -5,13 +5,34 @@ description: "Code:\n\n\"\\\"aiken\\\"\"" ByteArray { location: 0..11, bytes: [ - 34, - 97, - 105, - 107, - 101, - 110, - 34, + ( + 34, + 0..0, + ), + ( + 97, + 0..0, + ), + ( + 105, + 0..0, + ), + ( + 107, + 0..0, + ), + ( + 101, + 0..0, + ), + ( + 110, + 0..0, + ), + ( + 34, + 0..0, + ), ], preferred_format: Utf8String, } diff --git a/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled.snap b/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled.snap index d6274e00..8465d580 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled.snap @@ -12,11 +12,26 @@ Call { value: ByteArray { location: 13..20, bytes: [ - 65, - 105, - 107, - 101, - 110, + ( + 65, + 0..0, + ), + ( + 105, + 0..0, + ), + ( + 107, + 0..0, + ), + ( + 101, + 0..0, + ), + ( + 110, + 0..0, + ), ], preferred_format: Utf8String, }, diff --git a/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled_with_field_access.snap b/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled_with_field_access.snap index f4738e38..0a78f3a4 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled_with_field_access.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled_with_field_access.snap @@ -12,11 +12,26 @@ Call { value: ByteArray { location: 25..32, bytes: [ - 65, - 105, - 107, - 101, - 110, + ( + 65, + 0..0, + ), + ( + 105, + 0..0, + ), + ( + 107, + 0..0, + ), + ( + 101, + 0..0, + ), + ( + 110, + 0..0, + ), ], preferred_format: Utf8String, }, diff --git a/crates/aiken-lang/src/parser/expr/snapshots/record_update_basic.snap b/crates/aiken-lang/src/parser/expr/snapshots/record_update_basic.snap index 69e8ebb8..ed9dc549 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/record_update_basic.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/record_update_basic.snap @@ -22,11 +22,26 @@ RecordUpdate { value: ByteArray { location: 21..28, bytes: [ - 65, - 105, - 107, - 101, - 110, + ( + 65, + 0..0, + ), + ( + 105, + 0..0, + ), + ( + 107, + 0..0, + ), + ( + 101, + 0..0, + ), + ( + 110, + 0..0, + ), ], preferred_format: Utf8String, }, diff --git a/crates/aiken-lang/src/parser/expr/snapshots/todo_expr.snap b/crates/aiken-lang/src/parser/expr/snapshots/todo_expr.snap index 3dd7a245..a1f6e174 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/todo_expr.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/todo_expr.snap @@ -19,18 +19,36 @@ Trace { ByteArray { location: 18..23, bytes: [ - 102, - 111, - 111, + ( + 102, + 0..0, + ), + ( + 111, + 0..0, + ), + ( + 111, + 0..0, + ), ], preferred_format: Utf8String, }, ByteArray { location: 25..30, bytes: [ - 98, - 97, - 114, + ( + 98, + 0..0, + ), + ( + 97, + 0..0, + ), + ( + 114, + 0..0, + ), ], preferred_format: Utf8String, }, diff --git a/crates/aiken-lang/src/parser/expr/snapshots/trace_expr.snap b/crates/aiken-lang/src/parser/expr/snapshots/trace_expr.snap index b64f649e..b40bd112 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/trace_expr.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/trace_expr.snap @@ -20,18 +20,36 @@ Trace { ByteArray { location: 19..24, bytes: [ - 102, - 111, - 111, + ( + 102, + 0..0, + ), + ( + 111, + 0..0, + ), + ( + 111, + 0..0, + ), ], preferred_format: Utf8String, }, ByteArray { location: 26..31, bytes: [ - 98, - 97, - 114, + ( + 98, + 0..0, + ), + ( + 97, + 0..0, + ), + ( + 114, + 0..0, + ), ], preferred_format: Utf8String, }, diff --git a/crates/aiken-lang/src/parser/literal/bytearray.rs b/crates/aiken-lang/src/parser/literal/bytearray.rs index 84bfe188..c305a3ed 100644 --- a/crates/aiken-lang/src/parser/literal/bytearray.rs +++ b/crates/aiken-lang/src/parser/literal/bytearray.rs @@ -10,7 +10,7 @@ use crate::{ pub fn parser( into: impl Fn( - Vec, + Vec<(u8, ast::Span)>, ast::ByteArrayFormatPreference, Option, ast::Span, @@ -20,7 +20,13 @@ pub fn parser( choice(( array_of_bytes(), hex_string(), - utf8_string().map(|(p, b)| (None, p, b)), + utf8_string().map(|(p, b)| { + ( + None, + p, + b.into_iter().map(|b| (b, ast::Span::empty())).collect(), + ) + }), )) .validate(move |(curve, preferred_format, bytes), span, emit| { into(bytes, preferred_format, curve, span, emit) @@ -66,7 +72,7 @@ pub fn array_of_bytes() -> impl Parser< ( Option, ast::ByteArrayFormatPreference, - Vec, + Vec<(u8, ast::Span)>, ), Error = ParseError, > { @@ -86,14 +92,14 @@ pub fn array_of_bytes() -> impl Parser< 0 } }; - (byte, base) + (byte, base, span) }) .separated_by(just(Token::Comma)) .allow_trailing() .delimited_by(just(Token::LeftSquare), just(Token::RightSquare)), ) .validate(|(curve, bytes), span, emit| { - let base = bytes.iter().try_fold(None, |acc, (_, base)| match acc { + let base = bytes.iter().try_fold(None, |acc, (_, base, _)| match acc { None => Ok(Some(base)), Some(previous_base) if previous_base == base => Ok(Some(base)), _ => Err(()), @@ -114,7 +120,10 @@ pub fn array_of_bytes() -> impl Parser< ( curve, - bytes.into_iter().map(|(b, _)| b).collect::>(), + bytes + .into_iter() + .map(|(b, _, span)| (b, span)) + .collect::>(), base, ) }) @@ -132,7 +141,7 @@ pub fn hex_string() -> impl Parser< ( Option, ast::ByteArrayFormatPreference, - Vec, + Vec<(u8, ast::Span)>, ), Error = ParseError, > { @@ -153,7 +162,7 @@ pub fn hex_string() -> impl Parser< ( curve, ast::ByteArrayFormatPreference::HexadecimalString, - token, + token.into_iter().map(|b| (b, ast::Span::empty())).collect(), ) }) } diff --git a/crates/aiken-lang/src/parser/pattern/snapshots/pattern_bytearray.snap b/crates/aiken-lang/src/parser/pattern/snapshots/pattern_bytearray.snap index a23e6a4c..e46266f4 100644 --- a/crates/aiken-lang/src/parser/pattern/snapshots/pattern_bytearray.snap +++ b/crates/aiken-lang/src/parser/pattern/snapshots/pattern_bytearray.snap @@ -15,9 +15,18 @@ When { ByteArray { location: 18..27, value: [ - 0, - 171, - 205, + ( + 0, + 0..0, + ), + ( + 171, + 0..0, + ), + ( + 205, + 0..0, + ), ], preferred_format: HexadecimalString, }, @@ -33,19 +42,58 @@ When { ByteArray { location: 40..55, value: [ - 65, - 105, - 107, - 101, - 110, - 44, - 32, - 114, - 111, - 99, - 107, - 115, - 33, + ( + 65, + 0..0, + ), + ( + 105, + 0..0, + ), + ( + 107, + 0..0, + ), + ( + 101, + 0..0, + ), + ( + 110, + 0..0, + ), + ( + 44, + 0..0, + ), + ( + 32, + 0..0, + ), + ( + 114, + 0..0, + ), + ( + 111, + 0..0, + ), + ( + 99, + 0..0, + ), + ( + 107, + 0..0, + ), + ( + 115, + 0..0, + ), + ( + 33, + 0..0, + ), ], preferred_format: Utf8String, }, @@ -61,10 +109,22 @@ When { ByteArray { location: 68..81, value: [ - 1, - 2, - 3, - 4, + ( + 1, + 70..71, + ), + ( + 2, + 73..74, + ), + ( + 3, + 76..77, + ), + ( + 4, + 79..80, + ), ], preferred_format: ArrayOfBytes( Decimal { @@ -84,9 +144,18 @@ When { ByteArray { location: 94..113, value: [ - 0, - 171, - 205, + ( + 0, + 96..100, + ), + ( + 171, + 102..106, + ), + ( + 205, + 108..112, + ), ], preferred_format: ArrayOfBytes( Hexadecimal, diff --git a/crates/aiken-lang/src/snapshots/parse_unicode_offset_1.snap b/crates/aiken-lang/src/snapshots/parse_unicode_offset_1.snap index 29f96a21..25037f2b 100644 --- a/crates/aiken-lang/src/snapshots/parse_unicode_offset_1.snap +++ b/crates/aiken-lang/src/snapshots/parse_unicode_offset_1.snap @@ -18,9 +18,18 @@ Module { value: ByteArray { location: 21..26, bytes: [ - 226, - 152, - 133, + ( + 226, + 0..0, + ), + ( + 152, + 0..0, + ), + ( + 133, + 0..0, + ), ], preferred_format: Utf8String, }, diff --git a/crates/aiken-lang/src/snapshots/parse_unicode_offset_2.snap b/crates/aiken-lang/src/snapshots/parse_unicode_offset_2.snap index f491a175..9b47388a 100644 --- a/crates/aiken-lang/src/snapshots/parse_unicode_offset_2.snap +++ b/crates/aiken-lang/src/snapshots/parse_unicode_offset_2.snap @@ -18,7 +18,10 @@ Module { value: ByteArray { location: 21..24, bytes: [ - 42, + ( + 42, + 0..0, + ), ], preferred_format: Utf8String, }, diff --git a/crates/aiken-lang/src/tests/format.rs b/crates/aiken-lang/src/tests/format.rs index 0c4c1c65..9988d875 100644 --- a/crates/aiken-lang/src/tests/format.rs +++ b/crates/aiken-lang/src/tests/format.rs @@ -44,6 +44,21 @@ fn format_nul_byte() { ); } +#[test] +fn format_allow_comments_in_byte_array() { + assert_format!( + r#" + pub const thing = + #[ + // thing + 0x12, + // wow + 0x10, + ] + "# + ); +} + #[test] fn format_g1_element_constant() { assert_format!( diff --git a/crates/aiken-lang/src/tests/snapshots/format_allow_comments_in_byte_array.snap b/crates/aiken-lang/src/tests/snapshots/format_allow_comments_in_byte_array.snap new file mode 100644 index 00000000..9a254a58 --- /dev/null +++ b/crates/aiken-lang/src/tests/snapshots/format_allow_comments_in_byte_array.snap @@ -0,0 +1,11 @@ +--- +source: crates/aiken-lang/src/tests/format.rs +description: "Code:\n\npub const thing =\n #[\n // thing\n 0x12,\n // wow\n 0x10,\n ]\n" +--- +pub const thing = + #[ + // thing + 0x12, + // wow + 0x10, + ] diff --git a/crates/aiken-lang/src/tipo/expr.rs b/crates/aiken-lang/src/tipo/expr.rs index 6ba7557f..f1d9a035 100644 --- a/crates/aiken-lang/src/tipo/expr.rs +++ b/crates/aiken-lang/src/tipo/expr.rs @@ -555,7 +555,11 @@ impl<'a, 'b> ExprTyper<'a, 'b> { bytes, preferred_format, location, - } => self.infer_bytearray(bytes, preferred_format, location), + } => self.infer_bytearray( + bytes.into_iter().map(|(b, _)| b).collect(), + preferred_format, + location, + ), UntypedExpr::CurvePoint { location, diff --git a/crates/aiken-lang/src/tipo/pattern.rs b/crates/aiken-lang/src/tipo/pattern.rs index 0062f2d5..76b15249 100644 --- a/crates/aiken-lang/src/tipo/pattern.rs +++ b/crates/aiken-lang/src/tipo/pattern.rs @@ -210,7 +210,7 @@ impl<'a, 'b> PatternTyper<'a, 'b> { Ok(Pattern::ByteArray { location, - value, + value: value.into_iter().map(|(b, _)| b).collect(), preferred_format, }) } diff --git a/crates/aiken-project/src/config.rs b/crates/aiken-project/src/config.rs index 9c93da78..580fa8e5 100644 --- a/crates/aiken-project/src/config.rs +++ b/crates/aiken-project/src/config.rs @@ -126,7 +126,7 @@ impl SimpleExpr { }, SimpleExpr::ByteArray(bs, preferred_format) => UntypedExpr::ByteArray { location: Span::empty(), - bytes: bs.to_vec(), + bytes: bs.iter().map(|b| (*b, Span::empty())).collect(), preferred_format: *preferred_format, }, SimpleExpr::List(es) => match annotation {