Repository: mesonbuild/meson

Issue:
AttributeError: 'Interpreter' object has no attribute 'builtin'
I just updated to the latest master and got this stackdump.

``` python
mkdir build
python3 ./ECS/MDP1/meson/meson.py --buildtype=debugoptimized build
The Meson build system
Version: 0.36.0.dev1
Source dir: /tmp/foo
Build dir: /tmp/foo/build
Build type: native build
Traceback (most recent call last):
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/mesonmain.py", line 282, in run
    app.generate()
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/mesonmain.py", line 159, in generate
    intr = interpreter.Interpreter(b, g)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 1129, in __init__
    self.sanity_check_ast()
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 1258, in sanity_check_ast
    args = self.reduce_arguments(first.args)[0]
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2387, in reduce_arguments
    reduced_kw[key] = self.evaluate_statement(a)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 1435, in evaluate_statement
    return self.evaluate_arraystatement(cur)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2744, in evaluate_arraystatement
    (arguments, kwargs) = self.reduce_arguments(cur.args)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2381, in reduce_arguments
    reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments]
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2381, in <listcomp>
    reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments]
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 1423, in evaluate_statement
    return self.method_call(cur)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2515, in method_call
    return self.string_method_call(obj, method_name, args)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2434, in string_method_call
    (posargs, _) = self.reduce_arguments(args)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2381, in reduce_arguments
    reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments]
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2381, in <listcomp>
    reduced_pos = [self.evaluate_statement(arg) for arg in args.arguments]
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 1423, in evaluate_statement
    return self.method_call(cur)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 2505, in method_call
    obj = self.get_variable(object_name)
  File "/tmp/foo/ECS/MDP1/meson/mesonbuild/interpreter.py", line 1308, in get_variable
    if varname in self.builtin:
AttributeError: 'Interpreter' object has no attribute 'builtin'
```



Discussion:
Hi jussi, I just updated to today's master (e2b3752f8757) and I'm still seeing this error. I'm stuck. Can you help me figure out what's going on?


Resolving patch:
diff --git a/mesonbuild/interpreter.py b/mesonbuild/interpreter.py
--- a/mesonbuild/interpreter.py
+++ b/mesonbuild/interpreter.py
@@ -1128,7 +1128,7 @@ def __init__(self, build, backend, subproject='', subdir='', subproject_dir='sub
             raise me
         self.sanity_check_ast()
         self.variables = {}
-        self.builtin = {}
+        self.builtin = {'meson': MesonMain(build, self)}
         self.generators = []
         self.visited_subdirs = {}
         self.global_args_frozen = False
@@ -1150,7 +1150,6 @@ def __init__(self, build, backend, subproject='', subdir='', subproject_dir='sub
                 self.builtin['target_machine'] = CrossMachineInfo(cross_info.config['target_machine'])
             else:
                 self.builtin['target_machine'] = self.builtin['host_machine']
-        self.builtin['meson'] = MesonMain(build, self)
         self.build_def_files = [os.path.join(self.subdir, environment.build_filename)]
 
     def build_func_dict(self):
@@ -1254,9 +1253,6 @@ def sanity_check_ast(self):
         first = self.ast.lines[0]
         if not isinstance(first, mparser.FunctionNode) or first.func_name != 'project':
             raise InvalidCode('First statement must be a call to project')
-        args = self.reduce_arguments(first.args)[0]
-        if len(args) < 2:
-            raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
 
 
     def check_cross_stdlibs(self):
@@ -1615,6 +1611,8 @@ def func_project(self, node, args, kwargs):
             self.build.project_name = args[0]
             if self.environment.first_invocation and 'default_options' in kwargs:
                 self.parse_default_options(kwargs['default_options'])
+        if len(args) < 2:
+            raise InvalidArguments('Not enough arguments to project(). Needs at least the project name and one language')
         self.active_projectname = args[0]
         self.project_version = kwargs.get('version', 'undefined')
         proj_license = mesonlib.stringlistify(kwargs.get('license', 'unknown'))


Test patch: