Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type annotations are ignorred when module contains error #108

Open
alex35mil opened this issue Aug 22, 2018 · 6 comments
Open

Type annotations are ignorred when module contains error #108

alex35mil opened this issue Aug 22, 2018 · 6 comments

Comments

@alex35mil
Copy link

alex35mil commented Aug 22, 2018

E.g.

let foo = (arg: array(Foo.t)) => ... some error here ...
/*                    ^                                   */
/*                    hover, cmd+click etc don't work     */
@alex35mil alex35mil changed the title Type annotations are ignorred Type annotations are ignorred when module contains error Aug 22, 2018
@jaredly
Copy link
Owner

jaredly commented Aug 22, 2018

Yup, most analysis depends on not having type errors :)

@jaredly
Copy link
Owner

jaredly commented Aug 22, 2018

if you have an error in a later structure item, you can get analysis for anything leading up to it.
image

@jaredly jaredly added the lowpri Probably won't be worked on soon label Aug 26, 2018
@jaredly
Copy link
Owner

jaredly commented Aug 26, 2018

I could do that hack that merlin does and input an any type in place of a type error, but it can lead to spurious errors.

@jaredly
Copy link
Owner

jaredly commented Aug 26, 2018

Orr I guess if it's a straight up type annotation, I could try to resolve that by hand... but that's hard to do correctly. Maybe best effort would be fine there?

@jaredly jaredly removed the lowpri Probably won't be worked on soon label Aug 27, 2018
@alex35mil
Copy link
Author

alex35mil commented Aug 28, 2018

Orr I guess if it's a straight up type annotation, I could try to resolve that by hand... but that's hard to do correctly. Maybe best effort would be fine there?

When I started using Reason toolchain my first source of confusion was the difference in how toolchain and compiler see a code. E.g. when I passed record that wasn't in scope to some function compiler told me that I don't know what this argument is but when I was hovering argument tooling was giving me expected (by me) type. It was super confusing b/c I assumed that tooling and compiler has single source of this information. So I'd stick to compiler as much as possible in terms of exposing what the things are.

Just to clarify my usecase that triggered this issue: I was passing argument to a function w/ explicit type annotation. Later on, inside this function I made a mistake in property name (of the annotated record) and toolchain showed me an error. I wanted to hover the type (annotation) or cmd + click on module in type annotation to look at the type but toolchain simply ignored this part. So my expectations were similar: if compiler knows what this thing is then toolchain should know this as well so I can use its functionality to work w/ this type.

I really haven't looked into tooling internals and have zero understanding how these parts work together so not sure how hard it is to share the compiler's vision of code w/ toolchain. But I assume this is what the most of developers expect.

@PhiLhoSoft
Copy link

I searched the list of issues to see if it has been already reported.
I am new to Reason, I follow the https://medium.freecodecamp.org/learn-reasonml-by-building-tic-tac-toe-in-react-334203dd513c tutorial, so I build the app progressively, thus I have errors when I have something not defined yet.

And I find this a bit confusing (I am used to TypeScript dev, which doesn't work like that... it highlights all types errors in a file, for example).
I have an underlined error (wrong type) in the middle of a source, I get type definitions above the error, and nothing below. Which is annoying because inspecting the code below can lead to hints how to fix this error...

I understand it can be hard to fix, I have no idea how IDEs manage to resume code analysis after this kind of error (forcing "any" to resume analysis looks like a good idea), so any "best effort" in the domain would be welcome, it can help a lot beginners like me.

Thank you for this nice extension, it is already very useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants