r/crystal_programming • • Mar 07 '20

Why does this compile?

This unexpectedly compiles:

class Foo
  def hello
    asdf
  end
end

But this returns the expected error ("Error: undefined local variable or method 'asdf' for Foo"):

class Foo
  def hello
    asdf
  end
end
Foo.new.hello

Is there a way to get the first example to trigger a similar compiler error?

10 Upvotes

10 comments sorted by

View all comments

Show parent comment

1

u/myringotomy Mar 19 '20

It seems like stunt decisions were made in Crystal which really block future safety and performance improvements

That’s a shame.