Skip to content

Fixed Context struct to have usize instead of i32 - #20

Open
wdoppenberg wants to merge 3 commits into
CurrySoftware:masterfrom
wdoppenberg:fix/armenian-context
Open

Fixed Context struct to have usize instead of i32#20
wdoppenberg wants to merge 3 commits into
CurrySoftware:masterfrom
wdoppenberg:fix/armenian-context

Conversation

@wdoppenberg

@wdoppenberg wdoppenberg commented Aug 23, 2023

Copy link
Copy Markdown

I kept getting an error as follows:

error[E0308]: mismatched types
   --> src/snowball/algorithms/armenian.rs:352:26
    |
352 |     env.limit_backward = context.i_pV;
    |     ------------------   ^^^^^^^^^^^^ expected `usize`, found `i32`
    |     |
    |     expected due to the type of this binding

For more information about this error, try `rustc --explain E0308`.

This was easily fixed by changing the Context struct's fields to be usize.

  • ran cargo test

Furthermore, I added a basic GH Actions workflow to run cargo test.

@simunic-cz simunic-cz mentioned this pull request Apr 27, 2024
Ngalstyan4 added a commit to Ngalstyan4/rust-stemmers that referenced this pull request Sep 13, 2024
It seems at some point snowball_env.rs has been updated in the rust
snowball backend but the change is not reflected in rust-stemmers
project.

The right fix probably is to fix snowball_env.rs and regenerate all rust
code for language-specific stemmers. But this small change at least
makes the main branch compile out of the box again.

See CurrySoftware#20 for an additional github action suggestion that runs tests on
PRs
@ojwb

ojwb commented Aug 6, 2026

Copy link
Copy Markdown

This type incompatibility comes from using an old version of Snowball's rust runtime with rust code generated by a newer version of the Snowball compiler.

i_pV comes from a Snowball integer variable which can have negative values and so really does need to be a signed type, but the original rust output and runtime used an unsigned type. That was fixed in 2018 (by snowballstem/snowball@64419d4) - this PR is trying to effectively revert the effects of that on generated rust code.

The best fix is a wholesale upgrade to the latest Snowball compiler and runtime, but if you really want/need to patch older stuff, make limit_backward, limit, cursor, etc i32 instead.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants