Repository navigation
fix(aff): consult AF aliases for numeric flag types - #20
Merged
the-mikedavis merged 1 commit intoJul 11, 2026
Merged
Conversation
Member
|
This looks correct to me. I don't really remember the reasoning for this fast-lane - I might've just assumed that numeric flags can't use aliases. I'm not sure how I feel about code from Claude though, ideally I want contributions to be understood fully by their implementor. Would you mind taking another swing at this from scratch, knowing the fix direction? If I get a chance I will try to do the same (and credit you with co-author of course). |
Contributor
Author
|
Thanks for taking a look. I understand the reluctance to accept AI generated code given the huge amounts of slop being generated. Rationale for leaning on AI here:
However, feel free to own the implementation/reimplement if you are more comfortable with that approach. |
decode_flagset took a fast lane for `FLAG num` that decoded the field as
a literal numeric flag without checking the AF alias table. With both
`FLAG num` and an AF table, a `.dic` entry like `word/1` produced the
literal flag {1} instead of expanding alias helix-editor#1, so aliased affix rules
never matched.
An AF table should take priority over the flag type, as Hunspell does in
HashMgr::load_tables. Gate the fast lane on `aliases.is_empty()` alone;
the existing alias-index lookup then covers numeric dictionaries too, and
out-of-range or non-integer fields still fall through to the literal
decode.
I hit this with the Korean dictionary, whose josa suffix rules are all
referenced through AF aliases, so every suffixed word was wrongly flagged
as misspelled.
PeterToulouras
force-pushed
the
fix-af-alias-numeric-flag
branch
from
July 11, 2026 01:16
6a9611a to
ede3fda
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
decode_flagsethas a fast lane that decodes a flag field as a literal flag wheneverFLAG numis set, without consulting theAFalias table. So for a dictionary that uses bothFLAG numandAF, an entry likeword/1ends up with the literal flag1instead of expanding alias#1, and any affix rule referenced through an alias fails to match.An
AFtable should take priority over the flag type. Hunspell resolves the field as an alias index whenever the table is non-empty and only decodes a literal flag when there is no table: https://github.com/hunspell/hunspell/blob/2969be996acad84b91ab3875b1816636fe61a40e/src/hunspell/hashmgr.cxx#L652-L660. Nuspell does the same, andhunspell.5doesn't specify the precedence.The fix drops the
FlagType::Numericshort-circuit so the fast lane only applies when there are no aliases. The existing alias-index lookup then covers numeric dictionaries too, and out-of-range indices or non-integer fields still fall through to the literal decode unchanged.I ran into this with the Korean dictionary: it uses
FLAG numwith anAFtable, and its suffix (josa) rules are all referenced through aliases, so with the fast lane every suffixed word was reported as misspelled.I extended
decode_flagset_testto cover alias resolution underFLAG numalong with the out-of-range and no-alias-table fallbacks.