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

Configure Feed

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

Improve implicit todo warning wording

Closes https://github.com/gleam-lang/gleam/issues/5979

+49 -27
+4 -2
compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___just_use_in_fn_body.snap
··· 20 20 3 │ use <- wibble() 21 21 │ ^^^^^^^^^^^^^^^ This code is incomplete 22 22 23 - This code will crash if it is run. Be sure to finish it before 24 - running your program. 25 23 A use expression must always be followed by at least one expression. 24 + 25 + A todo expression has been use in place of the missing code, so 26 + this code will crash if it is run. Be sure to finish it before 27 + running your program.
+4 -2
compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__use___no_callback_body.snap
··· 17 17 4 │ use <- thingy() 18 18 │ ^^^^^^^^^^^^^^^ This code is incomplete 19 19 20 - This code will crash if it is run. Be sure to finish it before 21 - running your program. 22 20 A use expression must always be followed by at least one expression. 21 + 22 + A todo expression has been use in place of the missing code, so 23 + this code will crash if it is run. Be sure to finish it before 24 + running your program.
+4 -1
compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__empty_func_warning_test.snap
··· 14 14 2 │ pub fn wibble() { } 15 15 │ ^^^^^^^^^^^^^^^ This code is incomplete 16 16 17 - This code will crash if it is run. Be sure to finish it before 17 + A function must always have an implementation. 18 + 19 + A todo expression has been use in place of the missing body, 20 + so this code will crash if it is run. Be sure to finish it before 18 21 running your program.
+4 -2
compiler-core/src/type_/tests/snapshots/gleam_core__type___tests__warnings__incomplete_code_block_raises_warning.snap
··· 16 16 3 │ {} 17 17 │ ^^ This code is incomplete 18 18 19 - This code will crash if it is run. Be sure to finish it before 20 - running your program. 21 19 A block must always contain at least one expression. 20 + 21 + A todo expression has been use in place of the missing code, 22 + so this code will crash if it is run. Be sure to finish it before 23 + running your program.
+33 -20
compiler-core/src/warning.rs
··· 440 440 type_, 441 441 names, 442 442 } => { 443 - let mut text = String::new(); 444 - text.push_str( 445 - "\ 443 + let (title, text) = match kind { 444 + TodoKind::Keyword => { 445 + let text = "\ 446 446 This code will crash if it is run. Be sure to finish it before 447 - running your program.", 448 - ); 449 - let title = match kind { 450 - TodoKind::Keyword => "Todo found", 447 + running your program."; 448 + 449 + ("Todo found", text) 450 + } 451 + 451 452 TodoKind::EmptyBlock => { 452 - text.push_str( 453 - " 454 - A block must always contain at least one expression.", 455 - ); 456 - "Incomplete block" 453 + let text = "\ 454 + A block must always contain at least one expression. 455 + 456 + A todo expression has been use in place of the missing code, 457 + so this code will crash if it is run. Be sure to finish it before 458 + running your program."; 459 + ("Incomplete block", text) 460 + } 461 + TodoKind::EmptyFunction { .. } => { 462 + let text = "\ 463 + A function must always have an implementation. 464 + 465 + A todo expression has been use in place of the missing body, 466 + so this code will crash if it is run. Be sure to finish it before 467 + running your program."; 468 + ("Unimplemented function", text) 457 469 } 458 - TodoKind::EmptyFunction { .. } => "Unimplemented function", 459 470 TodoKind::IncompleteUse => { 460 - text.push_str( 461 - " 462 - A use expression must always be followed by at least one expression.", 463 - ); 464 - "Incomplete use expression" 471 + let text = "\ 472 + A use expression must always be followed by at least one expression. 473 + 474 + A todo expression has been use in place of the missing code, so 475 + this code will crash if it is run. Be sure to finish it before 476 + running your program."; 477 + ("Incomplete use expression", text) 465 478 } 466 479 } 467 480 .into(); ··· 476 489 }; 477 490 478 491 Diagnostic { 479 - title, 480 - text, 492 + title: title.into(), 493 + text: text.into(), 481 494 level: diagnostic::Level::Warning, 482 495 location: Some(Location { 483 496 path: path.to_path_buf(),