datawire / quark

Quark is a specialized language for defining and implementing communication protocols in multiple languages.
http://datawire.github.io/quark/
Apache License 2.0
98 stars 24 forks source link

Compiler Crashes when Using Generics #143

Open plombardi89 opened 8 years ago

plombardi89 commented 8 years ago
    interface Supplier<T> 
    {

      @doc("Gets a value")
      T get();

      @doc("Gets a value or if null returns the given alternative.")
      T orElseGet(T alternative) 
      {
        T result = get();
        if (result != null) 
        {
          return result;
        }
        else
        {
          return alternative;
        }
      }

    }

Used the explain-dispatch-error branch to get more resolution into the issue:

Compiling quark code ...
Internal compiler error:
  compiler was looking at [call depth 1/8]:
/home/plombardi/workspace/dw2/daas/discovery/quark/test.q:5:24: TypeParam T arg 0
  compiler was looking at [call depth 2/8]:
/home/plombardi/workspace/dw2/daas/discovery/quark/test.q:15:13: Attr  arg 0
  compiler was looking at [call depth 3/8]:
/home/plombardi/workspace/dw2/daas/discovery/quark/test.q:15:13: Call  arg 0
  compiler was looking at [call depth 4/8]:
/home/plombardi/workspace/dw2/daas/discovery/quark/test.q:15:9: If  arg 0
  compiler was looking at [call depth 5/8]:
/home/plombardi/workspace/dw2/daas/discovery/quark/test.q:13:7: Block  arg 0
  compiler was looking at [call depth 6/8]:
/home/plombardi/workspace/dw2/daas/discovery/quark/test.q:12:7: Method orElseGet arg 0
  compiler was looking at [call depth 7/8]:
/home/plombardi/workspace/dw2/daas/discovery/quark/test.q:1:1: Interface Supplier arg 0
  compiler was looking at [call depth 8/8]:
/home/plombardi/workspace/dw2/daas/discovery/quark/test.q:1:1: Package test arg 0
​
​
Traceback (most recent call last):
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/command.py", line 184, in main
    compiler.compile(url, output, *backends)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/compiler.py", line 1273, in compile
    c.compile()
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/compiler.py", line 1216, in compile
    self.icompile(root)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/compiler.py", line 1138, in icompile
    ast.traverse(res)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 115, in traverse
    c.traverse(visitor, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 115, in traverse
    c.traverse(visitor, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 115, in traverse
    c.traverse(visitor, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 115, in traverse
    c.traverse(visitor, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 115, in traverse
    c.traverse(visitor, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 115, in traverse
    c.traverse(visitor, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 115, in traverse
    c.traverse(visitor, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 115, in traverse
    c.traverse(visitor, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/ast.py", line 116, in traverse
    leave(self, *args, **kwargs)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/compiler.py", line 593, in leave_Attr
    a.resolved = a.expr.resolved.get(a.attr, self.errors)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/compiler.py", line 333, in get
    for env in self.environments(self.type, bindings):
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/dispatch.py", line 52, in __call__
    method = self.get(types)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/dispatch.py", line 47, in get
    self.dispatcher.error(types)
  File "/home/plombardi/.quark/venv/lib/python2.7/site-packages/quarkc/dispatch.py", line 93, in error
    args)
DispatchError: environments has no matching method: (TypeParam, dict) ( 8 frames ) 
Internal compiler error, please report to https://github.com/datawire/quark/issues
ark3 commented 8 years ago

This is still an issue, though the crash is different. At the moment, the crash occurs even if Supplier<T> is a class instead of an interface.