Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG] gtr and ltr are wrong when a range has two bounds on the same side

Aperta
#904 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

@Prafyl ci sta già lavorando.

Dal 21/9/2026.

  • #905 di @Prafyl — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
76/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
tooling

Direzione di ricerca

Start in ranges/outside.js and reproduce the gtr/ltr examples from the issue with semver 7.8.5. Trace how comparator bounds are selected for ranges with multiple bounds on one side, then verify that gtr and ltr only return true when the version is beyond the complete range, including the README hole example.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Is there an existing issue for this?
  • I have searched the existing issues
Current Behavior

gtr and ltr give the wrong answer when a comparator set has more than one bound on the same side, and a lot of the time they both return true for the same version and range.

semver.gtr('1.5.0', '>1.0.0 >=2.0.0 <3.0.0') // true, but 1.5.0 is below the range
semver.ltr('1.5.0', '>1.0.0 >=2.0.0 <3.0.0') // true
semver.gtr('1.5.0', '>=2.0.0 <3.0.0')        // false

The README example about the hole in 1.2 <1.2.9 || >2.0.0 hits it too, it says 1.2.10 is not less than that range but semver.ltr('1.2.10', '1.2 <1.2.9 || >2.0.0') returns true. 1.2 expands to >=1.2.0 <1.3.0-0 so that set ends up with two upper bounds.

Expected Behavior

gtr should only be true if the version is greater than every version in the range, and ltr the same the other way, so they shouldnt both be true.

Steps To Reproduce

Run the snippet above. The cause is in ranges/outside.js, it takes the comparators with the highest and lowest versions as the edges of the set, which only works when there is one bound on each side. With >1.0.0 >=2.0.0 <3.0.0 it uses >1.0.0 as the lower edge, so 1.5.0 isnt below it, and since it doesnt satisfy the range it gets counted as above it. i checked gtr/ltr against a brute force answer on about 97k random version/range pairs and 7.8.5 was wrong on around 13% of them.

Environment
  • semver: 7.8.5 (same on main)
  • Node: 22.17.1
  • OS: Windows 11
Lingua principale
JavaScript
Stelle
5.5k
Fork
617
Merge medio
4g 23h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di npm/node-semver

Tutte le issue di npm/node-semver

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.