Closed pwseo closed 3 weeks ago
Some follow-up to what I have mentioned above: if I remove the account type: C
tag from Node:Leaf B
, suddenly it starts working correctly:
$ cat a.j
account Node:Leaf A ; type: Cash
$ cat b.j
account Node:Leaf B
$ hledger -s -f a.j accounts --types
Node:Leaf A ; type: C
Node:Leaf B ; type:
Is there a file-scoped limit for account type tags? If so, I was not aware (and did not expect it, since account
directives are global). Still, it seems like a bug is at play: when the type
tag is read from an included file, previous tags are being discarded.
Okay, so things are a little bit weirder than I antecipated.
This behaviour manifests only for type
tags with the same value.
Let's see another similar example:
$ cat a.j
account Node:Leaf A ; type: C
include b.j
include c.j
$ cat b.j
account Node:Leaf B ; type: C
$ cat c.j
account Node:Leaf C ; type: C
In this case, both Node:Leaf A
and Node:Leaf B
tags are ignored, only Node:Leaf C
is kept:
$ hledger -s -f a.j accounts --types
Node:Leaf A ; type:
Node:Leaf B ; type:
Node:Leaf C ; type: C
If we were to change Node:Leaf B
to another type, both Node:Leaf B
and Node:Leaf C
would be correctly typed. Node:Leaf A
's type will still be blank:
$ sed -i b.j -e 's/type: C/type: X/'
$ hledger -s -f a.j accounts --types
Node:Leaf A ; type:
Node:Leaf B ; type: X
Node:Leaf C ; type: C
And finally, if we change Node:Leaf A
's type tag to something else, everything works:
$ sed -i a.j -e 's/type: C/type: R/'
$ hledger -s -f a.j accounts --types
Node:Leaf A ; type: R
Node:Leaf B ; type: X
Node:Leaf C ; type: C
I agree, that is weird. Thanks for the report.
@simonmichael, I believe the commits 531d34a and a18425c should reference issue #2201.
I agree, that is weird. Thanks for the report.
I tried running hledger
with --debug=9
but didn't find anything that might help.
Can I help with anything else? (my Haskell skills are not very good).
@simonmichael, I believe the commits 531d34a and a18425c should reference issue #2201.
Right you are! I edited and force-pushed them.
I tried running hledger with --debug=9 but didn't find anything that might help. Can I help with anything else? (my Haskell skills are not very good).
I appreciate that. I tried the same, then I started adding dbg0 calls and reloading in ghci (just ghci
). I have seen that Hledger.Read.Common.addDeclaredAccountTags is adding each tag declaration, but on each call it sees that jdeclaredaccounttags j
is empty, which is strange (it should be accumulating results from each call.
I believe this is now fixed in master. Good catch (a bug with the original implementation of type:, not a regression).
It is fixed indeed! I thank you for your dedication to this project :)
Account
type:
tags seem to be inconsistently recognized.I have set up a minimum working example:
Now we use hledger's accounts' listing and request the account types as well:
Shouldn't
Node:Leaf A
also be oftype: C
?-- Note: this does not happen if all account directives with type tags are declared in the same file.