crystal-lang / crystal_lib

Automatic binding generator for native libraries in Crystal
138 stars 30 forks source link

Compile failure in latest release #20

Closed oprypin closed 8 years ago

oprypin commented 8 years ago

First off, this may be a problem with the compiler itself, but other libs work under the same circumstances

Steps to reproduce:

Run Ubuntu 14.04, for example:

vagrant init ubuntu/trusty64
vagrant up
vagrant ssh
curl http://dist.crystal-lang.org/apt/setup.sh | sudo bash
sudo apt-get install -qy build-essential llvm-3.6-dev crystal git
git clone https://github.com/crystal-lang/crystal_lib
cd crystal_lib/
crystal spec

Error:

Error in /opt/crystal/src/compiler/crystal/types.cr:2149: expanding macro

    getter link_attributes : Array(LinkAttribute)?
    ^~~~~~

in macro 'getter' /opt/crystal/src/object.cr:221, line 3:

  1.     
  2.       
  3.         @link_attributes : Array(LinkAttribute) | ::Nil
  4.         
  5.       
  6. 
  7.       def link_attributes
  8.         @link_attributes
  9.       end
 10.     
 11.   

        @link_attributes : Array(LinkAttribute) | ::Nil
                                 ^~~~~~~~~~~~~

undefined constant LinkAttribute

Some other things I tried: https://travis-ci.org/BlaXpirit/crystal-lib/builds

asterite commented 8 years ago

Thank you for reporting this, @BlaXpirit

The problem is because of these lines:

require "compiler/crystal/*"
require "compiler/crystal/syntax/parser"
require "compiler/crystal/syntax/transformer"
require "compiler/crystal/semantic/*"

They don't require the full compiler's source, and because of new type annotations they now don't work because some types are not imported. It's fixed if we change it to:

require "compiler/crystal/**"

That's a temporary solution I will apply.

In the long term, the compiler's source code should be organized in a way that only the syntax, or syntax+semantic parts of the compiler could be required, but right now that's not the case (so it's better to just require the whole thing).

asterite commented 8 years ago

I was initially a bit worried that we introduced a regression in the compiler, but doesn't seem like it :sweat_smile: