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

Errors with terrible output #30

Open
xarvh opened this issue Mar 29, 2024 · 3 comments
Open

Errors with terrible output #30

xarvh opened this issue Mar 29, 2024 · 3 comments

Comments

@xarvh
Copy link
Owner

xarvh commented Mar 29, 2024

No description provided.

@xarvh
Copy link
Owner Author

xarvh commented Apr 16, 2024

  listCons as fn item: item =
      fn item:
      []

Error message:

        This is a literal variant, which means its type must always be a variant type.
        
        However the annotation for `listCons`:
        
        
        says that it must have type
        
            1
        
        I need the annotation and the value to have the same type!

@xarvh
Copy link
Owner Author

xarvh commented Sep 15, 2024

We should make it clear that { type } should be { with type }.

This does not compile:

    selfType as TA.RawType =
        try Dict.get selfUsr env.expandedAliases as
            'nothing: bug "no self?"
            'just { type }: type

because

src/Compiler/TypeCheck.sp 949:8 

  949 |         try Dict.get selfUsr env.expandedAliases as
               ^^^
  950 |             'nothing: bug "no self?"
  951 |             'just { type }: type
  
  record attrs don't match
  $Context_LetInBody
      ["selfType"]
  
  $Why_TypeArgument
      ($USR
          ($UMR
              ($ImportsPath
                  $Core
                  ""
              )
              "src"
              "Maybe"
          )
          "Maybe"
      )
      0
      $Why_TryPattern
  
  TYPE 1 -----------------------
  { pars = core:/src/Core.List (core:/src/Core.Number), type = core:/src/Compiler/TypedAst.RawType }
  
  TYPE 2 -----------------------
  { type = 7338 }

@xarvh
Copy link
Owner Author

xarvh commented Oct 21, 2024

FAIL !  / TypeCheck / functions / [reg] Free tyvar should not be compatible with constructor

  listCons as fn item: item =
      fn item:
      []
  Error message:
        
        The annotation says that this variant literal should be of type:
        1
        
        However variant literals must always be of a var(iant) type.
        
        The two types are not compatible!
        [[context: $Context_LetInBody
            ["listCons"]
        ]]

Type variables are especially difficult to think about, so it might be worth to have special errors for them.

For example, in this case we could have something like:
"""
item is a free type variable, which means that, inside the function, it should be compatible with any type.
However inside the function it is used as a variant #xyz which has always type #type.
"""

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

1 participant