-
Notifications
You must be signed in to change notification settings - Fork 2
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
Trace back unification error #339
base: main
Are you sure you want to change the base?
Trace back unification error #339
Conversation
MangoIV
commented
Oct 27, 2024
•
edited
Loading
edited
- see issue unifier error messages appear in the wrong place #338
- add a very basic nix development environment
- work in process of annotating the origin of an error
- move the type error type into the heap to avoid warning
- annotate ast with a bit more information what each of the nodes mean
831c717
to
5314230
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some nitpick comments, looking good so far, otherwise, thanks for contributing :)
1233624
to
46e7757
Compare
46e7757
to
1f1ea1d
Compare
ah! that's because they don't have labels. Please excuse the fuzz. |
627f6d9
to
c8a3963
Compare
Wow, the new error messages already look much better 👍
I remember something about GH Actions being different on PRs and main due to security reasons? I don't have a good mental model for what happens when you change the configuration of GitHub actions in PRs. |
Yeah me either and it somehow always manages to surprise me so it probably won’t emerge any time soon lol |
c8a3963
to
31ef45a
Compare
I think most people will primarily interact with the error messages via the LSP editor integration. And the important thing is that you fixed the location of the squiggly lines for that use case (I just checked this myself). Also we don't report multiple errors for the same file currently (cp #65), so there is also a smaller likelihood that users are swamped by pages and pages of error messages. (LSP supports "related locations" for error messages. We could investigate in the future how well they work with these examples) |
that would be really nice! |
I think this is a great improvement. If you allow me to dream up an ideal textual error message for this scenario it might look like this:
|
Is there something you want me to do on this one? Otherwise I'd mark this as ready for review :) |
- add an origin field to NotEq unification error - add an origin field to CannotDecide unification error - reuse the span emitted for a data constructor without type for its type - Box the type error in Error to reduce the size of the enum
31ef45a
to
c035ca5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big improvement to our error messages, thank you!
I left some suggestions. Most of them are nitpicks. Please do check the comments on simplifying the test case, the reason
field and whether to use the spans of (co)cases rather than (co)matches.
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }} | ||
- name: Evaluate nix code | ||
run: nix -Lv flake check | ||
- name: build and run polarity using nix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- name: build and run polarity using nix | |
- name: Build and run polarity using nix |
run: nix -Lv flake check | ||
- name: build and run polarity using nix | ||
run: nix -Lv run .# -- --help | ||
- name: build and run a static polarity exe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- name: build and run a static polarity exe | |
- name: Build and run a static polarity exe |
- your changes use existing nixpkgs infrastructure where possible | ||
- your changes do not break any of the existing workflows and everything works as normal for non-nix users | ||
- your changes do not require changes in regular non-nix development workflows | ||
- your changes do not introduce any unnecessary IFD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe link to a reference on what IFD is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, I guess I will have to find one :P (https://nix.dev/manual/nix/2.25/language/import-from-derivation)
meta = { | ||
description = "A language with Dependendent Data and Codata Types"; | ||
homepage = "https://polarity-lang.github.io/"; | ||
licenses = with lib.licenses; [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the license
field, the docs say:
If the license field is in the form of a list representation, then it means that parts of the package are licensed differently
Is the semantic of the licenses
field different? Does this convey SPDX MIT OR Apache-2.0
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will look that up.
pub struct Fun { | ||
pub span: Span, | ||
pub from: Box<Exp>, | ||
pub to: Box<Exp>, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
/// Lambda abstractions \x. e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Lambda abstractions \x. e | |
/// Lambda abstractions (syntactic sugar), e.g. \x. e |
pub struct NatLit { | ||
pub span: Span, | ||
pub val: BigUint, | ||
} | ||
|
||
#[derive(Debug, Clone)] | ||
/// Function arrow in syntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/// Function arrow in syntax | |
/// Function arrow (syntactic sugar), e.g. a -> b |
@@ -35,6 +35,8 @@ pub enum TypeError { | |||
lhs_span: Option<SourceSpan>, | |||
#[label("Source of (2)")] | |||
rhs_span: Option<SourceSpan>, | |||
#[label("While elaborating")] | |||
reason_span: Option<SourceSpan>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if there's a better term than reason
to describe these fields. As far as I can see, this is always the span of the syntax tree node that is currently being elaborated.
I'm not sure I have a better term though; I've considered elab_origin_span
, while_elaborating_span
, ast_node_span
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm, I will probably take one of your options, I like while_elaborating_span
best, for now :)
@@ -33,7 +33,7 @@ impl CheckToplevel for Def { | |||
|
|||
let ws = WithScrutinee { cases, scrutinee: self_param_nf.expect_typ_app()? }; | |||
ws.check_exhaustiveness(ctx)?; | |||
let cases = ws.check_ws(ctx, &ret_typ_nf)?; | |||
let cases = ws.check_ws(ctx, &ret_typ_nf, span)?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want the span of the definition or of the case here? The same applies to top-level codefinitions and local (co)matches.
|
||
|
||
codef ZipWith(n : Type, f : (CoNat -> CoNat -> CoNat), l1:CoList(n), l2: CoList(n)) : CoList(n) { | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this test case can be simplified. E.g. remove unnecessary (co)definitions, or create a simpler example that produces the same kind of error.
For instance:
data Foo {}
data Bar(f: Foo) {}
let bar(a: Type): Bar(a) { ? }