Skip to content

Documentation regarding updatePosChar does not match the function's behaviour #129

@Pharap

Description

@Pharap

The documentation claims that:

If the character is a newline ('\n') or carriage return ('\r') the line number is incremented by 1.

(Specified here.)

But the actual definition does not do any special handling of '\r', thus leaving it to fall back to the default case behaviour of increasing the column number by 1.

updatePosChar :: SourcePos -> Char -> SourcePos
updatePosChar (SourcePos name line column) c
= case c of
'\n' -> SourcePos name (line+1) 1
'\t' -> SourcePos name line (column + 8 - ((column-1) `mod` 8))
_ -> SourcePos name line (column + 1)

I was initially going to submit a PR rectifying the comment (for which I prepared a commit), but I started wondering whether it's the comment that's wrong (i.e. that '\t' isn't supposed to behave that way) or the code itself (i.e. that '\t' should be specially handled and it isn't), so I decided to raise an issue first as a precaution.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions