You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from Standard.Base import all
import project.Mod.A
from project.Mod import make_a
type A
Ctor2
foo (a : A) -> A = a
main =
IO.println (foo (A.Ctor2))
IO.println (foo make_a)
running Main.enso will result in:
Ctor2
Execution finished with an error: Type error: expected `a` to be A, but got A.
at <enso> Main.foo(src\Main.enso:9:1-20)
at <enso> Main.main<arg-1>(src\Main.enso:13:17-26)
at <enso> Main.main(src\Main.enso:13:5-27)
There's 2 issues here:
The imported name A is shadowed by the type definition type A but this is not reported. If not error, at least a warning should be reported to the user about the shadowing.
The Type_Error message is confusing: expected A but got A - ???. The problem is that the qualified name of the types differs. We should record the qualified name of each type and if the short-names are equal, we should display the qualified names to allow the user to disambiguate types with same short names.
The content you are editing has changed. Please copy your edits and refresh the page.
According to @4e6 and @JaroslavTulach, type shadowing is perfectly fine. Imagine you would like to define your Boolean type. In that case, you would not be able to import all symbols from Standard.Base. Nevertheless, it should at least report a warning, as shadowing might not always be the desired behavior.
The type error message is indeed confusing. I will try to improve it.
According to @4e6 and @JaroslavTulach, type shadowing is perfectly fine. Imagine you would like to define your Boolean type. In that case, you would not be able to import all symbols from Standard.Base.
That's exactly the rationale behind the hiding construct.
If you want to define your own Boolean - that's perfectly fine, you need to use:
Within a project with 2 files:
Mod.enso
and
Main.enso
running
Main.enso
will result in:There's 2 issues here:
A
is shadowed by the type definitiontype A
but this is not reported. If not error, at least a warning should be reported to the user about the shadowing.Type_Error
message is confusing: expected A but got A - ???. The problem is that the qualified name of the types differs. We should record the qualified name of each type and if the short-names are equal, we should display the qualified names to allow the user to disambiguate types with same short names.Tasks
The text was updated successfully, but these errors were encountered: