Closed kbleeke closed 5 months ago
Actually, is seems like the return type of the imported function is already wrong in second case
Problem was that the type alias ResultType
was not resolved in the right module context.
The lsp-server 0.0.12 should handle this correctly now.
version 0.5.2.2 (Ckan)
Hi, Sorry for my ignorance, but I don't know what is a LSP-server, neither I know if this fix has been published on the version 0.5.2.2 available in Ckan.
However, it also seems to apply to Records elements :
gitreport/typeanalysis0.to2
pub type FancyConst = int
pub const FancyConstHolder: (Foo: FancyConst, Bar: FancyConst) = (
Foo: 0,
Bar: 1
)
pub fn foobar(p: FancyConst) -> Option<bool> = {
if (p == FancyConstHolder.Foo)
return Some(true)
else if (p == FancyConstHolder.Bar)
return Some(false)
return None()
}
gitreport/typeanalysis1.to2
use {FancyConstHolder, foobar} from gitreport::typeanalysis0
fn fancyFunc() -> Unit = {
foobar(FancyConstHolder.Foo)
}
give this error, which I think is linked with this topic :
Rebooted in 00:00:03.9095632 ERROR: [gitreport\typeanalysis0.to2(4, 35)] InvalidType Unable to lookup type FancyConst
Edit :
I forgot to mention an easy workaround is obviously to add FancyConst
in the import although I assume it shouldn't be mandatory.
The lsp-server is part of the visual studio code plugin. I release that part separately so that it could be used in other editors as well.
Your example was actually a bug in the compiler itself
This issue is stale because it has been open for 60 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
Consider the following structure
test2.to
test.to
The type for variable
a
is unkown. This can be worked around by importing ResultType as well.However, if the local module defines a type of the same name, the inferred type of
a
becomestest::ResultType
instead oftest2::ResultType