Coder Social home page Coder Social logo

Comments (11)

amaanq avatar amaanq commented on June 12, 2024 2

I'm not saying users who consume the actual library in their code should use this versioning strategy, it's only for these grammar bindings that wish to be used by these consumers such that whatever major version they decide to go with works totally fine in either case. So I still don't see how this would break, your code that uses this Language struct should be written for the appropriate version of tree-sitter (whether that be 0.20.10 or 0.21.0, or later on 0.22.0 etc). I think this is the easiest solution to prevent me having to manually update dozens of grammars every major update in the future, and really shouldn't cause breakage.

from tree-sitter-python.

jonhoo avatar jonhoo commented on June 12, 2024

This isn't really a bug, nor really a feature request, so both issue templates felt a little weird 😅

from tree-sitter-python.

clason avatar clason commented on June 12, 2024

Would be good to get an equivalent release of tree-sitter-python since the two versions need to match up.

[citation needed]

from tree-sitter-python.

jonhoo avatar jonhoo commented on June 12, 2024

[citation needed]

See the compiler error included in the post.

from tree-sitter-python.

clason avatar clason commented on June 12, 2024

That just means the lockfile has to be updated to the new release (or, in fact, the lockfile should never have pinned an exact version). It doesn't mean that tree-sitter-python needs a new version, nor that the version has to match that of tree-sitter exactly.

from tree-sitter-python.

jonhoo avatar jonhoo commented on June 12, 2024

No, that's not true. This is with a fully up-to-date lockfile. Rust (well, Cargo) considers different 0.x versions to be different major versions, and so when tree_sitter_python returns a tree_sitter::Language from tree_sitter 0.20.x, that type is considered to be distinct from (and incompatible/non-interchangeable with) tree_sitter::Language from tree_sitter 0.21.x. Hence the error.

from tree-sitter-python.

clason avatar clason commented on June 12, 2024

Yes, which means that the crate needs to (correctly) declare compatibility with multiple versions.

from tree-sitter-python.

jonhoo avatar jonhoo commented on June 12, 2024

You're proposing

tree-sitter = "~0.20.10"

should be updated to something like

tree-sitter = ">= 0.20.10"

?

I'd generally caution against that — Cargo very quickly gets sad once version ranges that aren't just at semver major version boundaries are involved.

from tree-sitter-python.

clason avatar clason commented on June 12, 2024

That is what I'm proposing, yes, since the current pin is insane from a maintenance point of view.

And, again, nothing here implies that tree-sitter-python needs a release, especially not at the same version.

from tree-sitter-python.

amaanq avatar amaanq commented on June 12, 2024

I'd generally caution against that — Cargo very quickly gets sad once version ranges that aren't just at semver major version boundaries are involved.

Honestly, I think it's fine for this specific case, because tree_sitter is pulled in only to export the C function that returns a Language. This type is just a wrapper around the C struct under the hood, and it will be fine to bump versions as this struct will almost never change, and if it does, it won't be in an incompatible way.

from tree-sitter-python.

jonhoo avatar jonhoo commented on June 12, 2024

In general, even if that kind of version range is appealing for exactly the reason you state, it also tends to come back to bite you in Rust, often in unintuitive ways. For example, since there will only be one major version of tree-sitter-python across 0.20 and 0.21, and Cargo will have to pick one version of tree-sitter to use, this will mean that consumers who may have multiple versions of tree-sitter in their dependency graph quickly run into problems when trying to get them to interoperate. There's a reason why exactly this pattern is called out in the Cargo docs as something you should be very careful with.

That's not to say "definitely don't do this", just to be aware that you may end up having to change it back later :)

from tree-sitter-python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.