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

dhall-docs: Prelude.head: empty list #2576

Open
kukimik opened this issue Mar 21, 2024 · 0 comments
Open

dhall-docs: Prelude.head: empty list #2576

kukimik opened this issue Mar 21, 2024 · 0 comments

Comments

@kukimik
Copy link
Collaborator

kukimik commented Mar 21, 2024

Running the dhall-docs executable from the 1.42.0 release on the following file:

let isZero = \(x : Natural) -> x === 0
let errorGeneratingDocs
	= \(n : Natural) -> \(p : isZero n) ->
		True
in errorGeneratingDocs

results in:

dhall-docs: Prelude.head: empty list

A binary I compiled myself reveals some more detail:

CallStack (from HasCallStack):
  error, called at libraries/base/GHC/List.hs:1646:3 in base:GHC.List
  errorEmptyList, called at libraries/base/GHC/List.hs:85:11 in base:GHC.List
  badHead, called at libraries/base/GHC/List.hs:81:28 in base:GHC.List
  head, called at src/Dhall/Docs/CodeRenderer.hs:378:127 in dhall-docs-1.0.11-inplace:Dhall.Docs.CodeRenderer

The relevant code is:

-- calls to `head` and `last` here should never fail since `importLines`
-- have at least one element
let (firstImportLine, lastImportLine) = (head importLines, last importLines)
let prefixCols = Text.take (importStartCol - currCol) firstImportLine
let suffixCols = Text.drop (importEndCol - currCol) lastImportLine

What I found out is that the bug seems somehow related to whitespace (e.g. removing the indentation or even replacing tabs with spaces makes the error disappear).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant