Fork of daniellemaywood.uk/gleam — Wasm codegen work
2

Configure Feed

Select the types of activity you want to include in your feed.

improve error message for constant bit arrays with non integer unit

+30 -2
+4
CHANGELOG.md
··· 271 271 that is not a literal number. 272 272 ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 273 273 274 + - Fixed a confusing error message when writing a constant bit array with a unit 275 + that is not a literal number. 276 + ([Giacomo Cavalieri](https://github.com/giacomocavalieri)) 277 + 274 278 - Fixed a bug where enabling `javascript.typescript_declarations` or 275 279 `javascript.source_maps` wouldn't generate their additional files unless the 276 280 build directory was manually deleted. The compiler now automatically rebuilds
+6 -2
compiler-core/src/parse.rs
··· 3803 3803 if self.maybe_one(&Token::LeftParen).is_some() { 3804 3804 // named function segment 3805 3805 match name.as_str() { 3806 - "unit" => match self.next_tok() { 3806 + "unit" => match self.tok0.take() { 3807 3807 Some((int_s, Token::Int { value, .. }, int_e)) => { 3808 + self.advance(); 3808 3809 let (_, end) = self.expect_one(&Token::RightParen)?; 3809 3810 let v = value.replace("_", ""); 3810 3811 match u8::from_str(&v) { ··· 3822 3823 }), 3823 3824 } 3824 3825 } 3825 - _ => self.next_tok_unexpected(vec!["positive integer".into()]), 3826 + tok0 => { 3827 + self.tok0 = tok0; 3828 + self.next_tok_unexpected(vec!["A positive integer".into()]) 3829 + } 3826 3830 }, 3827 3831 3828 3832 "size" => {
+16
compiler-core/src/parse/snapshots/gleam_core__parse__tests__parsing_bit_array_constant_with_non_integer_unit.snap
··· 1 + --- 2 + source: compiler-core/src/parse/tests.rs 3 + expression: "pub const wibble = <<1:unit(something)>>" 4 + --- 5 + ----- SOURCE CODE 6 + pub const wibble = <<1:unit(something)>> 7 + 8 + ----- ERROR 9 + error: Syntax error 10 + ┌─ /src/parse/error.gleam:1:29 11 + 12 + 1 │ pub const wibble = <<1:unit(something)>> 13 + │ ^^^^^^^^^ I was not expecting this 14 + 15 + Found a name, expected one of: 16 + - A positive integer
+4
compiler-core/src/parse/tests.rs
··· 2375 2375 assert_module_error!("pub const wibble = <<1:size(something)>>"); 2376 2376 } 2377 2377 2378 + #[test] 2379 + fn parsing_bit_array_constant_with_non_integer_unit() { 2380 + assert_module_error!("pub const wibble = <<1:unit(something)>>"); 2381 + }