meson icon indicating copy to clipboard operation
meson copied to clipboard

Syntactically invalid `meson.build` files do not respect meson_version

Open eli-schwartz opened this issue 3 years ago • 2 comments

project(
    'test',
    meson_version: '>=2.3.0',
)

foo ======= bar

The imaginary ======= syntax is surely added in Meson 2.3.0, which is multiple major versions away. If users of those boring old early-2020s versions of Meson try building this project, they should get a clever error message like this:

t/meson.build:1:0: ERROR: Meson version is 0.99.99 but project requires >=2.3.0

But they don't, instead they get:

t/meson.build:14:6: ERROR: Expecting eof got equal.
foo ======= bar
      ^

A full log can be found at /home/eschwartz/git/meson/t/builddir/meson-logs/meson-log.txt

This is a contrived example, demonstrating the problem is valid on the latest versions of Meson. The actual real life example where this occurs is in https://github.com/Astrabit-ST/ModShot-Core/issues/87

Specifically, dictionaries were added in 0.47.0, but if you try to build a project with Meson 0.46.0 that uses one of them, you get this:

meson.build:16:11: ERROR:  lexer
compilers = {
           ^

It would be nice if we could somehow evaluate the project() function without first erroring out on incompatible, new syntax.

eli-schwartz avatar Nov 23 '22 01:11 eli-schwartz

This is a tricky one… I guess ideally it would use a different directive that could be evaluated easily without lexing the file, hence not requiring it to be valid for that version of the lexer, but it's too later for that now…

ePirat avatar Nov 29 '22 00:11 ePirat

Another approach would be to do two passes and simply read the file in bit by bit to see if we can find a project() function using the current lexer version, then evaluate that upfront.

eli-schwartz avatar Nov 29 '22 00:11 eli-schwartz

Wasn't this fixed by #11466 ?

bruchar1 avatar Mar 20 '23 17:03 bruchar1

Aha. Yes. I don't know why I didn't remember that I opened an issue for it.

eli-schwartz avatar Mar 20 '23 17:03 eli-schwartz