DamienCassou / flycheck-hledger

hledger checker for flycheck

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

parsing regression on non-Windows platforms

simonmichael opened this issue · comments

@shivjm, I'm sorry to report that #18's 0c25e7e "Correctly parse excerpts with line numbers anywhere in them" has broken matching on other OS's (tested on mac).

Thanks Simon. As we discussed on Matrix, that PR corrected the parsing of errors on Windows, yet I recently started having the same issue there with flycheck-hledger at e4f3a97 and hledger v1.32.1 (which is why I was asking whether the error messages had changed in the first place!), so I’m frankly bewildered. It’s as if something changed, but as you said, nothing has. All the existing tests still pass.

So far, I’ve found two messages that aren’t parsed:

hledger.exe: Error: C:\data\file.ledger:5:
1 | 2023-12-14 Payment 2
  |     card             USD -50
  |     expenses          USD 50

5 | 2023-12-12 Payment 1
  | ^^^^^^^^^^
  |     card             USD -25
  |     expenses          USD 25

Ordered dates checking is enabled, and this transaction's
date (2023-12-12) is out of order with the previous transaction.
Consider moving this entry into date order, or adjusting its date.
hledger.exe: Error: D:\Media\src\flycheck-hledger\tests\.\t.journal:2:13:
  |
2 |   card  -USD
  |             ^
unexpected newline
expecting '+', '-', or number

I see the same issue with b9db91e, which came before PR #18, but I’m not entirely sure I’ve tried it correctly.

At any rate, in the first case, I believe the problem is the blank line (no |) between the two blocks showing the error. In the second, I believe it’s that there’s only one newline after the error message. I’m working on a PR to fix both of these.

EDIT:
I’ll have to wait a few days before continuing work on the PR as I’m currently traveling. Sorry for the delay.

Hi @shivjm, any chance you could fix this ? Or @DamienCassou could revert it temporarily ? I'd like to fix something unrelated and I'm not sure of the state of master.

This might be something to look at also: when parsing for a windows drive letter, eg:

    bol "hledger" (optional ".exe") ": Error: " (file-name (optional alpha ":") (+ (not ":"))) ":" line ":" column ":\n"                                                          

won't it misparse an error in a file named with just one letter ? ("hledger: Error: a:1:12:")

Well, perhaps it isn't a problem in practice because hledger shows the full path.

Sorry, I’ve been looking into this on and off, but I get different results with the same translated regexes outside flycheck (where they work fine) and inside flycheck (where they don’t), which has me somewhat flummoxed. I’ll try to work on it again today.

I managed to fix the problem with extra context at last, as best I can tell. I realized the problem wasn’t the regexes but the order in which the patterns were tried: the new pattern with the context would never match.

Separately, I fixed the issue with errors like the one about the unexpected newline, which have fewer newlines than usual. I’m opening a PR.