Skip to content

Some errors in binding groups point to the wrong definition #3452

Description

@natefaubion
module BadUnknownTypeVariable where

import Prelude

test :: Int
test = go 10
  where
  ok :: Int -> Boolean
  ok = (_ == 0)

  go :: int -> Int
  go n | ok n = n
       | otherwise = go (n - 1)
[1/1 UndefinedTypeVariable] BadUnknownTypeVariable.purs:8:3

  8    ok :: Int -> Boolean
       ^^^^^^^^^^^^^^^^^^^^

  Type variable int is undefined.

  while checking the kind of int -> Int
  while checking that expression go 10
                                   where
                                   ok = \$0 ->
                                          (...) 0
                                   go = \n ->
                                          ...
    has type Int
  in value declaration test

Note the type int instead of Int in the type of go. This appears to be related to recursive binding groups. If I don't call go recursively, the error is correct.

module BadUnknownTypeVariable where

import Prelude

test :: Int
test = go 10
  where
  ok :: Int -> Boolean
  ok = (_ == 0)

  go :: int -> Int
  go n | ok n = n
       | otherwise = 0
[1/1 UndefinedTypeVariable] BadUnknownTypeVariable.purs:11:3

  11    go :: int -> Int
        ^^^^^^^^^^^^^^^^

  Type variable int is undefined.

  while checking the kind of int -> Int
  while checking that expression go 10
                                   where
                                   ok = \$0 ->
                                          (...) 0
                                   go = \n ->
                                          case n of
                                            ...
    has type Int
  in value declaration test

I think this might(?) be because of #3278 which just rethrows with all of the BindingGroupDeclaration spans in the hint. I think it's probably just printing the first source span in that set of hints. However in that case I'm confused why go and ok would be in the same recursive binding group, since only go is recursive. It's definitely not like that in the corefn, which is the only thing I've verified.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions