InseeFr / Trevas-TS

JavaScript engine for the Validation and Transformation Language
MIT License
9 stars 8 forks source link

`instr` function may not work as expected #124

Closed romaintailhurat closed 1 year ago

romaintailhurat commented 1 year ago

If we are to believe the VTL spec, the instr function should return:

instr("124", "3") → 0
instr("124", "1") → 1

but instead it actually returns:

instr("124", "3") → 0
instr("124", "1") → 0

so we are not able to distinguish between string patterns that are not here and string patterns starting at the 1st position (1 in VTL, not 0). 🥴

It's probably just a +1 problem with JS indexes.

NicoLaval commented 1 year ago

Fix 33416b6c6e35ff4192495ddda06b99a1a0a3b043