Skip to content

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

Open
@kukimik

Description

@kukimik

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).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions