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

Warnings are not reported if there are errors #474

Closed
paulyoung opened this issue Jun 5, 2019 · 5 comments
Closed

Warnings are not reported if there are errors #474

paulyoung opened this issue Jun 5, 2019 · 5 comments

Comments

@paulyoung
Copy link
Contributor

I merged master (at 9cb2c23) into paulyoung/language-server/#461 and started seeing the following issue:

Screen Shot 2019-06-05 at 4 38 47 PM
Screen Shot 2019-06-05 at 4 38 58 PM

It's sort of the opposite to the issue I reported in #440.

@paulyoung
Copy link
Contributor Author

Just to verify that it's not related to the LSP work, here it is from the command line:

λ cat Warnings.as && result/bin/asc -c Warnings.as
let foo = [1, true, ""];
let bar = if true 1 else "2";
// let baz = qux;

Warnings.as:1.11-1.24: warning, this array has type [Any] because elements have inconsistent types
Warnings.as:2.11-2.29: warning, this if has type Any because branches have inconsistent types,
true produces
  Nat
false produces
  Text
λ cat Warnings.as && result/bin/asc -c Warnings.as
let foo = [1, true, ""];
let bar = if true 1 else "2";
let baz = qux;

Warnings.as:3.11-3.14: type error, unbound variable qux

@paulyoung
Copy link
Contributor Author

Same thing with --check instead of -c.

@nomeata
Copy link
Collaborator

nomeata commented Jun 6, 2019

I don’t think we can solve this in all generality. The type checker usually just aborts if there is an error, to avoid further touching bad code. There are specific points where we allow the type checker to continue in a different part of the code (so I assume if the warning and the error are happening in separate blocks, both will be returned). But in this case, it can’t even know the type of baz, so it will not look at the recursive block at at all. (Remember that all definitions are mutually recursive.)

@nomeata
Copy link
Collaborator

nomeata commented Jun 6, 2019

See:

~/dfinity/actorscript/src $ cat warnings.as ; echo; ./asc -c warnings.as 
let foo = [1, true, ""];
let bar = if true 1 else "2";
let baz = qux;

warnings.as:3.11-3.14: type error, unbound variable qux

~/dfinity/actorscript/src $ cat warnings.as ; echo; ./asc -c warnings.as 
{
let foo = [1, true, ""];
let bar = if true 1 else "2";
};
{
let baz = qux;
};

warnings.as:2.11-2.24: warning, this array has type [Any] because elements have inconsistent types
warnings.as:3.11-3.29: warning, this if has type Any because branches have inconsistent types,
true produces
  Nat
false produces
  Text
warnings.as:6.11-6.14: type error, unbound variable qux

I think we can close this, as in its full generality this is unfixable (but of course still try to make the type checker recover from errors where possible).

@nomeata nomeata closed this as completed Jun 6, 2019
@nomeata
Copy link
Collaborator

nomeata commented Jun 6, 2019

Hmm. We can actually resolve names before type checking. So we could do a separate name resolution pass (like GHC does, called the renamer there) and identify the SCC of the mutual groups, and then do type-checking separately on them. This would contain unrecoverable errors much more, and maybe even improve type inference. But it would be a major refactoring, so probably not worth right now.

dfinity-bot added a commit that referenced this issue Jan 18, 2023
## Changelog for motoko-base:
Branch: next-moc
Commits: [dfinity/motoko-base@40e2d36e...551acc9a](dfinity/motoko-base@40e2d36...551acc9)

* [`3a8d1f44`](dfinity/motoko-base@3a8d1f4) test: List module ([dfinity/motoko-base⁠#457](https://togithub.com/dfinity/motoko-base/issues/457))
* [`d74cc136`](dfinity/motoko-base@d74cc13) Int documentation and unit tests ([dfinity/motoko-base⁠#473](https://togithub.com/dfinity/motoko-base/issues/473))
* [`7171ebe3`](dfinity/motoko-base@7171ebe) Fix typo in Int.neg() function name ([dfinity/motoko-base⁠#479](https://togithub.com/dfinity/motoko-base/issues/479))
* [`85e17dcb`](dfinity/motoko-base@85e17dc) Motoko 0.7.5
* [`489a7595`](dfinity/motoko-base@489a759) Add `Array.size()`
* [`15ec733a`](dfinity/motoko-base@15ec733) Fix `Array.size` example
* [`bafaab29`](dfinity/motoko-base@bafaab2) Remove extraneous closing brace
* [`bc011ec3`](dfinity/motoko-base@bc011ec) Add missing semicolon
* [`8e2057d1`](dfinity/motoko-base@8e2057d) fix: import in `Trie.mo`
* [`f884484b`](dfinity/motoko-base@f884484) Add 'mo:base' import sanity check
* [`70f291d7`](dfinity/motoko-base@70f291d) Add link to PR in reference check file
* [`e35fde03`](dfinity/motoko-base@e35fde0) feat: user-facing API for timers ([dfinity/motoko-base⁠#474](https://togithub.com/dfinity/motoko-base/issues/474))
* [`cf74656f`](dfinity/motoko-base@cf74656) doc: Text module ([dfinity/motoko-base⁠#458](https://togithub.com/dfinity/motoko-base/issues/458))
* [`b1d30ec1`](dfinity/motoko-base@b1d30ec) chore: add examples for CertifiedData ([dfinity/motoko-base⁠#469](https://togithub.com/dfinity/motoko-base/issues/469))
* [`a3233a47`](dfinity/motoko-base@a3233a4) doc: ExperimentalStableMemory module ([dfinity/motoko-base⁠#482](https://togithub.com/dfinity/motoko-base/issues/482))
* [`e52bc256`](dfinity/motoko-base@e52bc25) Small typo in CertifiedData ([dfinity/motoko-base⁠#490](https://togithub.com/dfinity/motoko-base/issues/490))
* [`3729c65c`](dfinity/motoko-base@3729c65) Float documentation and unit tests ([dfinity/motoko-base⁠#455](https://togithub.com/dfinity/motoko-base/issues/455))
* [`1fa5240f`](dfinity/motoko-base@1fa5240) Deque documentation and unit tests ([dfinity/motoko-base⁠#465](https://togithub.com/dfinity/motoko-base/issues/465))
* [`a6826315`](dfinity/motoko-base@a682631) RBTree documentation and unit tests ([dfinity/motoko-base⁠#472](https://togithub.com/dfinity/motoko-base/issues/472))
* [`edb24def`](dfinity/motoko-base@edb24de) ExperimentalCycles documentation (no unit tests) ([dfinity/motoko-base⁠#477](https://togithub.com/dfinity/motoko-base/issues/477))
* [`eded1b73`](dfinity/motoko-base@eded1b7) doc: Text module ([dfinity/motoko-base⁠#458](https://togithub.com/dfinity/motoko-base/issues/458))
* [`41736374`](dfinity/motoko-base@4173637) chore: add examples for CertifiedData ([dfinity/motoko-base⁠#469](https://togithub.com/dfinity/motoko-base/issues/469))
* [`f4255ddb`](dfinity/motoko-base@f4255dd) doc: ExperimentalStableMemory module ([dfinity/motoko-base⁠#482](https://togithub.com/dfinity/motoko-base/issues/482))
* [`d99cd69d`](dfinity/motoko-base@d99cd69) Small typo in CertifiedData ([dfinity/motoko-base⁠#490](https://togithub.com/dfinity/motoko-base/issues/490))
* [`859edc14`](dfinity/motoko-base@859edc1) Float documentation and unit tests ([dfinity/motoko-base⁠#455](https://togithub.com/dfinity/motoko-base/issues/455))
* [`384ef6ee`](dfinity/motoko-base@384ef6e) Deque documentation and unit tests ([dfinity/motoko-base⁠#465](https://togithub.com/dfinity/motoko-base/issues/465))
* [`f0cf4da4`](dfinity/motoko-base@f0cf4da) RBTree documentation and unit tests ([dfinity/motoko-base⁠#472](https://togithub.com/dfinity/motoko-base/issues/472))
* [`66a682af`](dfinity/motoko-base@66a682a) ExperimentalCycles documentation (no unit tests) ([dfinity/motoko-base⁠#477](https://togithub.com/dfinity/motoko-base/issues/477))
* [`b4b6caca`](dfinity/motoko-base@b4b6cac) Add `Array.size` ([dfinity/motoko-base⁠#494](https://togithub.com/dfinity/motoko-base/issues/494))
* [`a5910190`](dfinity/motoko-base@a591019) fix: non-local import in `Trie.mo` ([dfinity/motoko-base⁠#495](https://togithub.com/dfinity/motoko-base/issues/495))
* [`823b0b40`](dfinity/motoko-base@823b0b4) Add `Array.size` ([dfinity/motoko-base⁠#494](https://togithub.com/dfinity/motoko-base/issues/494))
* [`4e6a7554`](dfinity/motoko-base@4e6a755) fix: non-local import in `Trie.mo` ([dfinity/motoko-base⁠#495](https://togithub.com/dfinity/motoko-base/issues/495))
* [`98c96a57`](dfinity/motoko-base@98c96a5) doc: add some explanation and improve examples in `Func.mo` ([dfinity/motoko-base⁠#471](https://togithub.com/dfinity/motoko-base/issues/471))
* [`4f8d37b6`](dfinity/motoko-base@4f8d37b) Int8/16/32/64 documentation and unit tests ([dfinity/motoko-base⁠#475](https://togithub.com/dfinity/motoko-base/issues/475))
* [`ef40d9d4`](dfinity/motoko-base@ef40d9d) fix: Base library issues with `Float` ([dfinity/motoko-base⁠#480](https://togithub.com/dfinity/motoko-base/issues/480))
* [`842e2b95`](dfinity/motoko-base@842e2b9) Typo in Float documentation ([dfinity/motoko-base⁠#498](https://togithub.com/dfinity/motoko-base/issues/498))
* [`443fcf86`](dfinity/motoko-base@443fcf8) doc: Random module ([dfinity/motoko-base⁠#484](https://togithub.com/dfinity/motoko-base/issues/484))
* [`ed727604`](dfinity/motoko-base@ed72760) doc: add examples to trie  ([dfinity/motoko-base⁠#454](https://togithub.com/dfinity/motoko-base/issues/454))
* [`4b472cf9`](dfinity/motoko-base@4b472cf) fix `bitnot` for the `Nat*` family too ([dfinity/motoko-base⁠#504](https://togithub.com/dfinity/motoko-base/issues/504))
* [`78af93bd`](dfinity/motoko-base@78af93b) feat: fix TrieSet.equals, add TrieSet.isEmpty, TrieSet.isSubset; add tests ([dfinity/motoko-base⁠#503](https://togithub.com/dfinity/motoko-base/issues/503))
* [`22152e95`](dfinity/motoko-base@22152e9) bugfix: fix issue [dfinity/motoko-base⁠#492](https://togithub.com/dfinity/motoko-base/issues/492) plus some testing of Random.mo ([dfinity/motoko-base⁠#500](https://togithub.com/dfinity/motoko-base/issues/500))
* [`b2e6e584`](dfinity/motoko-base@b2e6e58) bugfix: fixes  [dfinity/motoko-base⁠#448](https://togithub.com/dfinity/motoko-base/issues/448) ([dfinity/motoko-base⁠#505](https://togithub.com/dfinity/motoko-base/issues/505))
* [`f602517f`](dfinity/motoko-base@f602517) Add examples and update docs for Stack ([dfinity/motoko-base⁠#470](https://togithub.com/dfinity/motoko-base/issues/470))
mergify bot pushed a commit that referenced this issue Jan 18, 2023
## Changelog for motoko-base:
Branch: next-moc
Commits: [dfinity/motoko-base@40e2d36e...551acc9a](dfinity/motoko-base@40e2d36...551acc9)

* [`3a8d1f44`](dfinity/motoko-base@3a8d1f4) test: List module ([dfinity/motoko-base⁠#457](https://togithub.com/dfinity/motoko-base/issues/457))
* [`d74cc136`](dfinity/motoko-base@d74cc13) Int documentation and unit tests ([dfinity/motoko-base⁠#473](https://togithub.com/dfinity/motoko-base/issues/473))
* [`7171ebe3`](dfinity/motoko-base@7171ebe) Fix typo in Int.neg() function name ([dfinity/motoko-base⁠#479](https://togithub.com/dfinity/motoko-base/issues/479))
* [`85e17dcb`](dfinity/motoko-base@85e17dc) Motoko 0.7.5
* [`489a7595`](dfinity/motoko-base@489a759) Add `Array.size()`
* [`15ec733a`](dfinity/motoko-base@15ec733) Fix `Array.size` example
* [`bafaab29`](dfinity/motoko-base@bafaab2) Remove extraneous closing brace
* [`bc011ec3`](dfinity/motoko-base@bc011ec) Add missing semicolon
* [`8e2057d1`](dfinity/motoko-base@8e2057d) fix: import in `Trie.mo`
* [`f884484b`](dfinity/motoko-base@f884484) Add 'mo:base' import sanity check
* [`70f291d7`](dfinity/motoko-base@70f291d) Add link to PR in reference check file
* [`e35fde03`](dfinity/motoko-base@e35fde0) feat: user-facing API for timers ([dfinity/motoko-base⁠#474](https://togithub.com/dfinity/motoko-base/issues/474))
* [`cf74656f`](dfinity/motoko-base@cf74656) doc: Text module ([dfinity/motoko-base⁠#458](https://togithub.com/dfinity/motoko-base/issues/458))
* [`b1d30ec1`](dfinity/motoko-base@b1d30ec) chore: add examples for CertifiedData ([dfinity/motoko-base⁠#469](https://togithub.com/dfinity/motoko-base/issues/469))
* [`a3233a47`](dfinity/motoko-base@a3233a4) doc: ExperimentalStableMemory module ([dfinity/motoko-base⁠#482](https://togithub.com/dfinity/motoko-base/issues/482))
* [`e52bc256`](dfinity/motoko-base@e52bc25) Small typo in CertifiedData ([dfinity/motoko-base⁠#490](https://togithub.com/dfinity/motoko-base/issues/490))
* [`3729c65c`](dfinity/motoko-base@3729c65) Float documentation and unit tests ([dfinity/motoko-base⁠#455](https://togithub.com/dfinity/motoko-base/issues/455))
* [`1fa5240f`](dfinity/motoko-base@1fa5240) Deque documentation and unit tests ([dfinity/motoko-base⁠#465](https://togithub.com/dfinity/motoko-base/issues/465))
* [`a6826315`](dfinity/motoko-base@a682631) RBTree documentation and unit tests ([dfinity/motoko-base⁠#472](https://togithub.com/dfinity/motoko-base/issues/472))
* [`edb24def`](dfinity/motoko-base@edb24de) ExperimentalCycles documentation (no unit tests) ([dfinity/motoko-base⁠#477](https://togithub.com/dfinity/motoko-base/issues/477))
* [`eded1b73`](dfinity/motoko-base@eded1b7) doc: Text module ([dfinity/motoko-base⁠#458](https://togithub.com/dfinity/motoko-base/issues/458))
* [`41736374`](dfinity/motoko-base@4173637) chore: add examples for CertifiedData ([dfinity/motoko-base⁠#469](https://togithub.com/dfinity/motoko-base/issues/469))
* [`f4255ddb`](dfinity/motoko-base@f4255dd) doc: ExperimentalStableMemory module ([dfinity/motoko-base⁠#482](https://togithub.com/dfinity/motoko-base/issues/482))
* [`d99cd69d`](dfinity/motoko-base@d99cd69) Small typo in CertifiedData ([dfinity/motoko-base⁠#490](https://togithub.com/dfinity/motoko-base/issues/490))
* [`859edc14`](dfinity/motoko-base@859edc1) Float documentation and unit tests ([dfinity/motoko-base⁠#455](https://togithub.com/dfinity/motoko-base/issues/455))
* [`384ef6ee`](dfinity/motoko-base@384ef6e) Deque documentation and unit tests ([dfinity/motoko-base⁠#465](https://togithub.com/dfinity/motoko-base/issues/465))
* [`f0cf4da4`](dfinity/motoko-base@f0cf4da) RBTree documentation and unit tests ([dfinity/motoko-base⁠#472](https://togithub.com/dfinity/motoko-base/issues/472))
* [`66a682af`](dfinity/motoko-base@66a682a) ExperimentalCycles documentation (no unit tests) ([dfinity/motoko-base⁠#477](https://togithub.com/dfinity/motoko-base/issues/477))
* [`b4b6caca`](dfinity/motoko-base@b4b6cac) Add `Array.size` ([dfinity/motoko-base⁠#494](https://togithub.com/dfinity/motoko-base/issues/494))
* [`a5910190`](dfinity/motoko-base@a591019) fix: non-local import in `Trie.mo` ([dfinity/motoko-base⁠#495](https://togithub.com/dfinity/motoko-base/issues/495))
* [`823b0b40`](dfinity/motoko-base@823b0b4) Add `Array.size` ([dfinity/motoko-base⁠#494](https://togithub.com/dfinity/motoko-base/issues/494))
* [`4e6a7554`](dfinity/motoko-base@4e6a755) fix: non-local import in `Trie.mo` ([dfinity/motoko-base⁠#495](https://togithub.com/dfinity/motoko-base/issues/495))
* [`98c96a57`](dfinity/motoko-base@98c96a5) doc: add some explanation and improve examples in `Func.mo` ([dfinity/motoko-base⁠#471](https://togithub.com/dfinity/motoko-base/issues/471))
* [`4f8d37b6`](dfinity/motoko-base@4f8d37b) Int8/16/32/64 documentation and unit tests ([dfinity/motoko-base⁠#475](https://togithub.com/dfinity/motoko-base/issues/475))
* [`ef40d9d4`](dfinity/motoko-base@ef40d9d) fix: Base library issues with `Float` ([dfinity/motoko-base⁠#480](https://togithub.com/dfinity/motoko-base/issues/480))
* [`842e2b95`](dfinity/motoko-base@842e2b9) Typo in Float documentation ([dfinity/motoko-base⁠#498](https://togithub.com/dfinity/motoko-base/issues/498))
* [`443fcf86`](dfinity/motoko-base@443fcf8) doc: Random module ([dfinity/motoko-base⁠#484](https://togithub.com/dfinity/motoko-base/issues/484))
* [`ed727604`](dfinity/motoko-base@ed72760) doc: add examples to trie  ([dfinity/motoko-base⁠#454](https://togithub.com/dfinity/motoko-base/issues/454))
* [`4b472cf9`](dfinity/motoko-base@4b472cf) fix `bitnot` for the `Nat*` family too ([dfinity/motoko-base⁠#504](https://togithub.com/dfinity/motoko-base/issues/504))
* [`78af93bd`](dfinity/motoko-base@78af93b) feat: fix TrieSet.equals, add TrieSet.isEmpty, TrieSet.isSubset; add tests ([dfinity/motoko-base⁠#503](https://togithub.com/dfinity/motoko-base/issues/503))
* [`22152e95`](dfinity/motoko-base@22152e9) bugfix: fix issue [dfinity/motoko-base⁠#492](https://togithub.com/dfinity/motoko-base/issues/492) plus some testing of Random.mo ([dfinity/motoko-base⁠#500](https://togithub.com/dfinity/motoko-base/issues/500))
* [`b2e6e584`](dfinity/motoko-base@b2e6e58) bugfix: fixes  [dfinity/motoko-base⁠#448](https://togithub.com/dfinity/motoko-base/issues/448) ([dfinity/motoko-base⁠#505](https://togithub.com/dfinity/motoko-base/issues/505))
* [`f602517f`](dfinity/motoko-base@f602517) Add examples and update docs for Stack ([dfinity/motoko-base⁠#470](https://togithub.com/dfinity/motoko-base/issues/470))
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

2 participants