muon icon indicating copy to clipboard operation
muon copied to clipboard

String version comparison not supported in binary expressions

Open amcn opened this issue 11 months ago • 3 comments

Under meson the following expression:

if '0.10.0' <= '0.20.0'
  message('0.10.0 <= 0.20.0')
endif

yields: Message: 0.10.0 <= 0.20.0

Under muon, it yields a type error: error expected type int, got str. Is this a deliberate choice?

amcn avatar Mar 18 '24 01:03 amcn

It's a tempting thought. Meson performs string lexical sort, and it's a logic error and a project bug to use it on numbers and expect them to sort coherently.

If meson removed the ability to lexically sort strings it's entirely possible no one would ever notice except for the people who realize they should have used the version_compare method all along.

eli-schwartz avatar Mar 18 '24 12:03 eli-schwartz

If a project can point to a valid use of this operator, I'll implement it. So far all I have seen is accidents like this where string.version_compare was clearly the intent.

annacrombie avatar Mar 21 '24 17:03 annacrombie

If meson removed the ability to lexically sort strings it's entirely possible no one would ever notice except for the people who realize they should have used the version_compare method all along.

Would there be any appetite to deprecate this usage in Meson? As in, issue a warning when this pattern is detected stating its future deprecation and then removing it in a future version?

amcn avatar Mar 28 '24 17:03 amcn

I'm going to close this for now as the implementation of the operator in meson seems like it was probably a mistake.

annacrombie avatar Jun 08 '24 10:06 annacrombie