bblfsh / sdk

Babelfish driver SDK
GNU General Public License v3.0
23 stars 27 forks source link

Incorrect check for invalid positions #416

Open dennwc opened 5 years ago

dennwc commented 5 years ago

In SDK we have a method that checks if a position is valid. But the "valid" is not defined precisely. For example, the SDK expects it to mean "position is set at least partially", while user-facing code like iterators assumes it means "values used in positions are in a valid range".

We must first define a separate function that checks the range (e.g. offset >= 0), and then find and update all the places that expect this condition to hold.

The quick fix would be to add a check to the positional iterator specifically.

Related to https://github.com/bblfsh/python-client/pull/172

creachadair commented 5 years ago

Maybe we can distinguish between "initialized" and "valid", where "initialized" captures the idea that the driver set position information for the object, and "valid" captures the idea that the position is in-bounds for the enclosing file?

I'm not deeply attached to those particular words, but I do think it makes sense to give these names of some kind in the documentation.