From c42b5a1e5ba655fb86423b147986e67be877f337 Mon Sep 17 00:00:00 2001 From: Folkert Date: Tue, 14 Apr 2020 21:27:29 +0200 Subject: [PATCH] improved phantom type message --- compiler/reporting/src/report.rs | 7 ++++++- compiler/reporting/tests/test_reporting.rs | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/compiler/reporting/src/report.rs b/compiler/reporting/src/report.rs index 89331eb685..2df5637ceb 100644 --- a/compiler/reporting/src/report.rs +++ b/compiler/reporting/src/report.rs @@ -425,7 +425,12 @@ pub fn can_problem<'b>( alloc.reflow(" alias definition:"), ]), alloc.region(variable_region), - alloc.reflow("Roc does not allow phantom type parameters!"), + alloc.reflow("Roc does not allow unused type parameters!"), + // TODO add link to this guide section + alloc.hint().append(alloc.reflow( + "If you want an unused type parameter (a so-called \"phantom type\"), \ + read the guide section on phantom data.", + )), ]), Problem::DuplicateRecordFieldValue { field_name, diff --git a/compiler/reporting/tests/test_reporting.rs b/compiler/reporting/tests/test_reporting.rs index 76abd42a60..c9823edb3d 100644 --- a/compiler/reporting/tests/test_reporting.rs +++ b/compiler/reporting/tests/test_reporting.rs @@ -2663,7 +2663,10 @@ mod test_reporting { 1 ┆ Foo a : [ Foo ] ┆ ^ - Roc does not allow phantom type parameters! + Roc does not allow unused type parameters! + + Hint: If you want an unused type parameter (a so-called "phantom + type"), read the guide section on phantom data. "# ), )