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

Configure Feed

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

make sure todo uses the correct type names

+94 -5
+3
Cargo.lock
··· 291 291 version = "0.6.3" 292 292 source = "registry+https://github.com/rust-lang/crates.io-index" 293 293 checksum = "230c5f1ca6a325a32553f8640d31ac9b49f2411e901e427570154868b46da4f7" 294 + dependencies = [ 295 + "serde", 296 + ] 294 297 295 298 [[package]] 296 299 name = "bincode"
+1 -1
compiler-core/Cargo.toml
··· 35 35 # Unicode grapheme traversal 36 36 unicode-segmentation = "1.13.2" 37 37 # Bijective (bi-directional) hashmap 38 - bimap = "0.6.3" 38 + bimap = { version = "0.6.3", features = ["serde"] } 39 39 # Parsing of arbitrary width int values 40 40 num-bigint = { version = "0.4.6", features = ["serde"] } 41 41 num-traits = "0.2.19"
+2 -1
compiler-core/src/type_/error.rs
··· 7 7 build::Target, 8 8 exhaustiveness::ImpossibleBitArraySegmentPattern, 9 9 parse::LiteralFloatValue, 10 - type_::{Type, expression::ComparisonOutcome}, 10 + type_::{Type, expression::ComparisonOutcome, printer::Names}, 11 11 }; 12 12 13 13 use ecow::EcoString; ··· 867 867 kind: TodoKind, 868 868 location: SrcSpan, 869 869 type_: Arc<Type>, 870 + names: Names, 870 871 }, 871 872 872 873 ImplicitlyDiscardedResult {
+1
compiler-core/src/type_/expression.rs
··· 577 577 kind, 578 578 location: warning_location, 579 579 type_: type_.clone(), 580 + names: self.environment.names.clone(), 580 581 }); 581 582 582 583 self.purity = Purity::Impure;
+1 -1
compiler-core/src/type_/printer.rs
··· 11 11 /// This class keeps track of what names are used for modules in the current 12 12 /// scope, so they can be printed in errors, etc. 13 13 /// 14 - #[derive(Debug, Clone, PartialEq, Eq, Default)] 14 + #[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)] 15 15 pub struct Names { 16 16 /// Types that exist in the current module, either defined or imported in an 17 17 /// unqualified fashion.
+23
compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__todo_uses_the_appropriate_type_name.snap
··· 1 + --- 2 + source: compiler-core/src/type_/tests/warnings.rs 3 + expression: "\npub fn curry(_f: fn(a, b) -> c) -> fn(a) -> fn(b) -> c {\n fn(_a: a) {\n todo\n }\n}" 4 + --- 5 + ----- SOURCE CODE 6 + 7 + pub fn curry(_f: fn(a, b) -> c) -> fn(a) -> fn(b) -> c { 8 + fn(_a: a) { 9 + todo 10 + } 11 + } 12 + 13 + ----- WARNING 14 + warning: Todo found 15 + ┌─ /src/warning/wrn.gleam:4:5 16 + 17 + 4 │ todo 18 + │ ^^^^ This code is incomplete 19 + 20 + This code will crash if it is run. Be sure to finish it before 21 + running your program. 22 + 23 + Hint: I think its type is `fn(b) -> c`.
+29
compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__todo_uses_the_appropriate_type_name_2.snap
··· 1 + --- 2 + source: compiler-core/src/type_/tests/warnings.rs 3 + expression: "\nimport wibble\npub fn main() {\n wibble.consume(todo)\n}" 4 + --- 5 + ----- SOURCE CODE 6 + -- wibble.gleam 7 + 8 + pub type Wibble 9 + pub fn consume(wibble: Wibble) -> Nil { todo } 10 + 11 + 12 + -- main.gleam 13 + 14 + import wibble 15 + pub fn main() { 16 + wibble.consume(todo) 17 + } 18 + 19 + ----- WARNING 20 + warning: Todo found 21 + ┌─ /src/warning/wrn.gleam:4:18 22 + 23 + 4 │ wibble.consume(todo) 24 + │ ^^^^ This code is incomplete 25 + 26 + This code will crash if it is run. Be sure to finish it before 27 + running your program. 28 + 29 + Hint: I think its type is `wibble.Wibble`.
+31
compiler-core/src/type_/tests/warnings.rs
··· 19 19 assert_warning!("pub fn main() { 1 == todo }"); 20 20 } 21 21 22 + // https://github.com/gleam-lang/gleam/issues/4164 23 + #[test] 24 + fn todo_uses_the_appropriate_type_name() { 25 + assert_warning!( 26 + " 27 + pub fn curry(_f: fn(a, b) -> c) -> fn(a) -> fn(b) -> c { 28 + fn(_a: a) { 29 + todo 30 + } 31 + }" 32 + ); 33 + } 34 + 35 + #[test] 36 + fn todo_uses_the_appropriate_type_name_2() { 37 + assert_warning!( 38 + ( 39 + "wibble", 40 + " 41 + pub type Wibble 42 + pub fn consume(wibble: Wibble) -> Nil { todo } 43 + " 44 + ), 45 + " 46 + import wibble 47 + pub fn main() { 48 + wibble.consume(todo) 49 + }" 50 + ); 51 + } 52 + 22 53 // https://github.com/gleam-lang/gleam/issues/1669 23 54 #[test] 24 55 fn todo_warning_correct_location() {
+3 -2
compiler-core/src/warning.rs
··· 11 11 TodoOrPanic, UnreachablePatternReason, 12 12 }, 13 13 expression::ComparisonOutcome, 14 - pretty::Printer, 14 + printer::Printer, 15 15 }, 16 16 }; 17 17 use camino::Utf8PathBuf; ··· 435 435 kind, 436 436 location, 437 437 type_, 438 + names, 438 439 } => { 439 440 let mut text = String::new(); 440 441 text.push_str( ··· 465 466 let hint = if !type_.is_variable() { 466 467 Some(format!( 467 468 "I think its type is `{}`.\n", 468 - Printer::new().pretty_print(type_, 0) 469 + Printer::new(&names).print_type(type_) 469 470 )) 470 471 } else { 471 472 None