Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ternary operator inside method call crashes the parser #5003

Closed
Akaricchi opened this issue Mar 1, 2019 · 3 comments
Closed

Ternary operator inside method call crashes the parser #5003

Akaricchi opened this issue Mar 1, 2019 · 3 comments

Comments

@Akaricchi
Copy link
Contributor

project('mesonfail')
foo = 'FOO=@0@'.format(get_option('foo') == 'bar' ? 0 : 1)
Traceback (most recent call last):
  File "/data/git/meson/mesonbuild/mesonmain.py", line 115, in run
    return options.run_func(options)
  File "/data/git/meson/mesonbuild/msetup.py", line 245, in run
    app.generate()
  File "/data/git/meson/mesonbuild/msetup.py", line 163, in generate
    self._generate(env)
  File "/data/git/meson/mesonbuild/msetup.py", line 180, in _generate
    intr = interpreter.Interpreter(b)
  File "/data/git/meson/mesonbuild/interpreter.py", line 2018, in __init__
    self.load_root_meson_file()
  File "/data/git/meson/mesonbuild/interpreterbase.py", line 379, in load_root_meson_file
    self.ast = mparser.Parser(code, self.subdir).parse()
  File "/data/git/meson/mesonbuild/mparser.py", line 514, in parse
    block = self.codeblock()
  File "/data/git/meson/mesonbuild/mparser.py", line 792, in codeblock
    curline = self.line()
  File "/data/git/meson/mesonbuild/mparser.py", line 786, in line
    return self.statement()
  File "/data/git/meson/mesonbuild/mparser.py", line 519, in statement
    return self.e1()
  File "/data/git/meson/mesonbuild/mparser.py", line 529, in e1
    value = self.e1()
  File "/data/git/meson/mesonbuild/mparser.py", line 522, in e1
    left = self.e2()
  File "/data/git/meson/mesonbuild/mparser.py", line 547, in e2
    left = self.e3()
  File "/data/git/meson/mesonbuild/mparser.py", line 556, in e3
    left = self.e4()
  File "/data/git/meson/mesonbuild/mparser.py", line 565, in e4
    left = self.e5()
  File "/data/git/meson/mesonbuild/mparser.py", line 574, in e5
    return self.e5add()
  File "/data/git/meson/mesonbuild/mparser.py", line 577, in e5add
    left = self.e5sub()
  File "/data/git/meson/mesonbuild/mparser.py", line 583, in e5sub
    left = self.e5mod()
  File "/data/git/meson/mesonbuild/mparser.py", line 589, in e5mod
    left = self.e5mul()
  File "/data/git/meson/mesonbuild/mparser.py", line 595, in e5mul
    left = self.e5div()
  File "/data/git/meson/mesonbuild/mparser.py", line 601, in e5div
    left = self.e6()
  File "/data/git/meson/mesonbuild/mparser.py", line 611, in e6
    return self.e7()
  File "/data/git/meson/mesonbuild/mparser.py", line 628, in e7
    left = self.method_call(left)
  File "/data/git/meson/mesonbuild/mparser.py", line 720, in method_call
    args = self.args()
  File "/data/git/meson/mesonbuild/mparser.py", line 692, in args
    a = ArgumentNode(s)
  File "/data/git/meson/mesonbuild/mparser.py", line 419, in __init__
    self.subdir = token.subdir
AttributeError: 'TernaryNode' object has no attribute 'subdir'
The Meson build system
Version: 0.49.999
Source dir: /tmp/mesonfail
Build dir: /tmp/mesonfail/build
Build type: native build
@Akaricchi
Copy link
Contributor Author

It looks like this bug is actually quite old; see #2404 #3690

@dcbaker
Copy link
Member

dcbaker commented Mar 2, 2019

Yup, I've run into this a few times myself.

@dcbaker
Copy link
Member

dcbaker commented Mar 2, 2019

I'm interested, I extended the test case, now let me see if I can fix the actual bug :)

dcbaker added a commit to dcbaker/meson that referenced this issue Mar 2, 2019
dcbaker added a commit to dcbaker/meson that referenced this issue Mar 2, 2019
Ternaries don't really need subdirs, but they can be passed into
functions that expect the type they're provided to have a
subdir. Provide it to fulful the interface.

Fixes mesonbuild#5003
Fixes mesonbuild#3690
Fixes mesonbuild#2404
dcbaker added a commit to dcbaker/meson that referenced this issue Mar 2, 2019
dcbaker added a commit to dcbaker/meson that referenced this issue Mar 2, 2019
Ternaries don't really need subdirs, but they can be passed into
functions that expect the type they're provided to have a
subdir. Provide it to fulful the interface.

Fixes mesonbuild#5003
Fixes mesonbuild#3690
Fixes mesonbuild#2404
tbeloqui pushed a commit to pexip/meson that referenced this issue Aug 22, 2019
* tests: extend ternary test to cover bugs

See issues mesonbuild#5003, mesonbuild#3690, and mesonbuild#2404

* mparser: store subdir in ternary node

Ternaries don't really need subdirs, but they can be passed into
functions that expect the type they're provided to have a
subdir. Provide it to fulful the interface.

Fixes mesonbuild#5003
Fixes mesonbuild#3690
Fixes mesonbuild#2404
anitazha added a commit to anitazha/systemd that referenced this issue Oct 25, 2019
Per mesonbuild/meson#5003, ternary doesn't
always work as function args with older versions of meson.
Expand out ternary statements to stay compatible with older versions (< 0.49).
keszybz pushed a commit to systemd/systemd that referenced this issue Oct 26, 2019
Per mesonbuild/meson#5003, ternary doesn't
always work as function args with older versions of meson.
Expand out ternary statements to stay compatible with older versions (< 0.49).
Yamakuzure pushed a commit to elogind/elogind that referenced this issue Feb 1, 2020
Per mesonbuild/meson#5003, ternary doesn't
always work as function args with older versions of meson.
Expand out ternary statements to stay compatible with older versions (< 0.49).
rzr added a commit to CrossStream/libglvnd that referenced this issue Jul 1, 2020
Ternary operator inside method call crashes the parser,
so it's relocated outside.

Bug: NVIDIA#198
Forwarded: https:/NVIDIA/libglvnd/pulls
Relate-to: mesonbuild/meson#5003
Signed-off-by: Philippe Coval <[email protected]>
Change-Id: I18b6e8eca7564a6a252fff1ec6299311a3a92669
rzr added a commit to CrossStream/libglvnd that referenced this issue Jul 1, 2020
Ternary operator inside method call crashes the parser,
so it's relocated outside.

This change will help to build project under latest debian:10

Forwarded: https://gitlab.freedesktop.org/glvnd/libglvnd/-/merge_requests
Bug: NVIDIA#198
Relate-to: mesonbuild/meson#5003
Signed-off-by: Philippe Coval <[email protected]>
Change-Id: I18b6e8eca7564a6a252fff1ec6299311a3a92669
ueno added a commit to ueno/p11-kit that referenced this issue Nov 27, 2020
While the minimum version requirement of meson is 0.49, the current
meson.build causes the parser crash, because of the use of a ternary
operator inside a function call:
mesonbuild/meson#5003
ueno added a commit to p11-glue/p11-kit that referenced this issue Nov 28, 2020
While the minimum version requirement of meson is 0.49, the current
meson.build causes the parser crash, because of the use of a ternary
operator inside a function call:
mesonbuild/meson#5003
ueno added a commit to p11-glue/p11-kit that referenced this issue Dec 11, 2020
While the minimum version requirement of meson is 0.49, the current
meson.build causes the parser crash, because of the use of a ternary
operator inside a function call:
mesonbuild/meson#5003
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants