mirror of
https://github.com/roc-lang/roc.git
synced 2025-12-23 08:48:03 +00:00
Revise error message for missing qualified types
This commit is contained in:
parent
8907f4241c
commit
7900cd31cd
5 changed files with 22 additions and 12 deletions
|
|
@ -889,9 +889,19 @@ pub const Diagnostic = union(enum) {
|
|||
) !Report {
|
||||
var report = Report.init(allocator, "UNDECLARED TYPE", .runtime_error);
|
||||
const owned_type_name = try report.addOwnedString(type_name);
|
||||
try report.document.addReflowingText("The type ");
|
||||
try report.document.addType(owned_type_name);
|
||||
try report.document.addReflowingText(" is not declared in this scope.");
|
||||
|
||||
// Check if this looks like a qualified type (contains dots)
|
||||
const has_dots = std.mem.indexOfScalar(u8, type_name, '.') != null;
|
||||
|
||||
if (has_dots) {
|
||||
try report.document.addReflowingText("Cannot resolve qualified type ");
|
||||
try report.document.addType(owned_type_name);
|
||||
try report.document.addReflowingText(".");
|
||||
} else {
|
||||
try report.document.addReflowingText("The type ");
|
||||
try report.document.addType(owned_type_name);
|
||||
try report.document.addReflowingText(" is not declared in this scope.");
|
||||
}
|
||||
try report.document.addLineBreak();
|
||||
try report.document.addLineBreak();
|
||||
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ import utils.String.Format exposing [padLeft]
|
|||
|
||||
|
||||
**UNDECLARED TYPE**
|
||||
The type _Config.Settings_ is not declared in this scope.
|
||||
Cannot resolve qualified type _Config.Settings_.
|
||||
|
||||
This type is referenced here:
|
||||
**can_import_nested_modules.md:6:21:6:30:**
|
||||
|
|
@ -126,7 +126,7 @@ authenticate = |user, pass| HttpAuth.login(user, pass)
|
|||
|
||||
|
||||
**UNDECLARED TYPE**
|
||||
The type _Config.Parser.Advanced_ is not declared in this scope.
|
||||
Cannot resolve qualified type _Config.Parser.Advanced_.
|
||||
|
||||
This type is referenced here:
|
||||
**can_import_nested_modules.md:14:28:14:37:**
|
||||
|
|
@ -137,7 +137,7 @@ processData : Config.Parser.Advanced, Str -> Result(Str, Config.Parser.Error)
|
|||
|
||||
|
||||
**UNDECLARED TYPE**
|
||||
The type _Config.Parser.Error_ is not declared in this scope.
|
||||
Cannot resolve qualified type _Config.Parser.Error_.
|
||||
|
||||
This type is referenced here:
|
||||
**can_import_nested_modules.md:14:71:14:77:**
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ json_encoder = Json.Core.Utf8.defaultEncoder
|
|||
|
||||
|
||||
**UNDECLARED TYPE**
|
||||
The type _json.Core.Utf8.Encoder_ is not declared in this scope.
|
||||
Cannot resolve qualified type _json.Core.Utf8.Encoder_.
|
||||
|
||||
This type is referenced here:
|
||||
**multi_qualified_import.md:7:25:7:33:**
|
||||
|
|
@ -180,7 +180,7 @@ process = |encoder| "processing"
|
|||
|
||||
|
||||
**UNDECLARED TYPE**
|
||||
The type _json.Core.Utf8.EncodedData_ is not declared in this scope.
|
||||
Cannot resolve qualified type _json.Core.Utf8.EncodedData_.
|
||||
|
||||
This type is referenced here:
|
||||
**multi_qualified_import.md:11:22:11:34:**
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ x = Foo.Bar.Baz.X
|
|||
UNDECLARED TYPE - nominal_undefined_deeply_nested_tag.md:5:12:5:16
|
||||
# PROBLEMS
|
||||
**UNDECLARED TYPE**
|
||||
The type _Foo.Bar.Baz_ is not declared in this scope.
|
||||
Cannot resolve qualified type _Foo.Bar.Baz_.
|
||||
|
||||
This type is referenced here:
|
||||
**nominal_undefined_deeply_nested_tag.md:5:12:5:16:**
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ aliasedQualified : ExtMod.DataType
|
|||
|
||||
|
||||
**UNDECLARED TYPE**
|
||||
The type _ExtMod.DataType_ is not declared in this scope.
|
||||
Cannot resolve qualified type _ExtMod.DataType_.
|
||||
|
||||
This type is referenced here:
|
||||
**qualified_type_canonicalization.md:19:26:19:35:**
|
||||
|
|
@ -187,7 +187,7 @@ aliasedQualified = ExtMod.DataType.Default
|
|||
|
||||
|
||||
**UNDECLARED TYPE**
|
||||
The type _ModuleA.ModuleB.TypeC_ is not declared in this scope.
|
||||
Cannot resolve qualified type _ModuleA.ModuleB.TypeC_.
|
||||
|
||||
This type is referenced here:
|
||||
**qualified_type_canonicalization.md:22:38:22:44:**
|
||||
|
|
@ -298,7 +298,7 @@ transform : Result.Result(Color.RGB, ExtMod.Error) -> ModuleA.ModuleB.TypeC
|
|||
|
||||
|
||||
**UNDECLARED TYPE**
|
||||
The type _ModuleA.ModuleB.TypeC_ is not declared in this scope.
|
||||
Cannot resolve qualified type _ModuleA.ModuleB.TypeC_.
|
||||
|
||||
This type is referenced here:
|
||||
**qualified_type_canonicalization.md:39:70:39:76:**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue