Don't allow non-equality comparisons across types.

pull/1810/head
Elliott Sales de Andrade 8 years ago
parent b36513a5b6
commit 0e56ec2dbd
  1. 5
      mesonbuild/interpreterbase.py
  2. 7
      test cases/failing/52 inconsistent comparison/meson.build

@ -221,6 +221,11 @@ class InterpreterBase:
return val1 == val2
elif node.ctype == '!=':
return val1 != val2
elif not isinstance(val1, type(val2)):
raise InterpreterException(
'Values of different types ({}, {}) cannot be compared using {}.'.format(type(val1).__name__,
type(val2).__name__,
node.ctype))
elif not self.is_elementary_type(val1):
raise InterpreterException('{} can only be compared for equality.'.format(node.left.value))
elif not self.is_elementary_type(val2):

@ -0,0 +1,7 @@
project('kwarg before arg', 'c')
# All of these should fail, though only the first one will error out if
# everything's working correctly.
assert([] < 'st', 'should fail')
assert([] < 1, 'should fail')
assert(2 < 'st', 'should fail')
Loading…
Cancel
Save