Skip to content

Fix source spans for binding groups - #3462

Merged
LiamGoodacre merged 1 commit into
purescript:masterfrom
LiamGoodacre:fix/source-span-binding-group
Jan 10, 2019
Merged

Fix source spans for binding groups#3462
LiamGoodacre merged 1 commit into
purescript:masterfrom
LiamGoodacre:fix/source-span-binding-group

Conversation

@LiamGoodacre

Copy link
Copy Markdown
Member

Moves the recursive call out of each previous item's source span.

Fixes #3452

It took me far too long to work out what was going on here 😅.

Just moduleName <- checkCurrentModule <$> get
inferLetBinding seen (ValueDecl sa@(ss, _) ident nameKind [] [MkUnguarded tv@(TypedValue checkType val ty)] : rest) ret j = do
Just moduleName <- checkCurrentModule <$> get
TypedValue _ val' ty'' <- warnAndRethrowWithPositionTC ss $ do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I correct in saying the issue is that warnAndRethrowWithPositionTC had a recursive call under it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh you said this in the main message 😆. I should read more closely.

@natefaubion

natefaubion commented Dec 1, 2018

Copy link
Copy Markdown
Contributor
             v
   6  test = go 10
   7    where
   8    ok :: Int -> Boolean
      ...
  11    go :: int -> Int
  12    go n | ok n = n
  13         | otherwise = go (n - 1)
                                   ^

  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

This now points to the correct definition, but the source span does not include the offending item. Is it possible to include the type signature in the span, or do we just drop all span relating to type signature?

Edit: I misread this error (not my day apparently). Is it possible to narrow this down to the go definition, or does it necessarily need to include the whole binding group?

@LiamGoodacre

Copy link
Copy Markdown
Member Author

@natefaubion I haven't checked yet but I suspect that the combination of this PR and #3463 will narrow the error down to the go declaration.

@natefaubion

Copy link
Copy Markdown
Contributor

@LiamGoodacre Do we want to go ahead and merge this as is and make follow-up improvements?

Moves the recursive call out of each previous item's source span.

Fixes #3452
@LiamGoodacre

Copy link
Copy Markdown
Member Author

@natefaubion yeah that sounds good.
I've just rebased against master.
Will need an approved review to merge.

@LiamGoodacre
LiamGoodacre merged commit 2beb8c8 into purescript:master Jan 10, 2019
@LiamGoodacre
LiamGoodacre deleted the fix/source-span-binding-group branch January 10, 2019 20:53
@garyb garyb mentioned this pull request Jan 12, 2019
3 tasks
dariooddenino pushed a commit to dariooddenino/purescript that referenced this pull request Jan 18, 2019
Moves the recursive call out of each previous item's source span.

Fixes purescript#3452
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

Successfully merging this pull request may close these issues.

2 participants