Move PNC apply to separate Expr/Pattern variant

This commit is contained in:
Anthony Bullard 2025-01-07 17:22:19 -06:00
parent 96fc573b6b
commit 898b3f55e5
No known key found for this signature in database
70 changed files with 873 additions and 555 deletions

View file

@ -23,7 +23,7 @@ use roc_parse::{
};
use roc_region::all::Loc;
use roc_region::all::Region;
use roc_test_utils::assert_multiline_str_eq;
use roc_test_utils::{assert_multiline_str_eq, pretty_compare_string};
use roc_types::{
subs::{VarStore, Variable},
types::{AliasVar, Type},
@ -392,6 +392,10 @@ impl<'a> Input<'a> {
// I don't have the patience to debug this right now, so let's leave it for another day...
// TODO: fix PartialEq impl on ast types
if format!("{ast_normalized:?}") != format!("{reparsed_ast_normalized:?}") {
pretty_compare_string(
format!("{ast_normalized:#?}").as_str(),
format!("{reparsed_ast_normalized:#?}").as_str(),
);
panic!(
"Formatting bug; formatting didn't reparse to the same AST (after removing spaces)\n\n\
* * * Source code before formatting:\n{}\n\n\
@ -411,6 +415,10 @@ impl<'a> Input<'a> {
let reformatted = reparsed_ast.format(flags);
if output != reformatted {
pretty_compare_string(
format!("{actual:#?}").as_str(),
format!("{reparsed_ast:#?}").as_str(),
);
eprintln!("Formatting bug; formatting is not stable.\nOriginal code:\n{}\n\nFormatted code:\n{}\n\nAST:\n{:#?}\n\nReparsed AST:\n{:#?}\n\n",
self.as_str(),
output.as_ref().as_str(),