vim-crystal icon indicating copy to clipboard operation
vim-crystal copied to clipboard

Arbitrary `undefined constant`

Open marceloboeira opened this issue 10 years ago • 10 comments

Example file structure:

src/
--my_lib.cr
--my_lib/
----a.cr
----a/
------b.cr

my_lib.cr

require "./my_lib/**"

module MyLib; end

my_lib/a/b.cr


module MyLib
  class A
    class B
       @example : String
    end
  end 
end

my_lib/a.cr


module MyLib
  class A
    @example : Array(MyLib::A::B)

    def initialize(@another : MyLib::A::B); end
  end 
end

When editing the a.cr file, the plugin generates an syntax error: undefined constant MyLib::A::B

Since probably the plugin is trying to compile/check the syntax only on this specific file, it is not able to find the reference to the class.

If I require my_lib/a/b.cr everything works well. Yet, on my_lib.cr all the files are required.

But the weirdest of all, is that this error does not occur on the initialize method reference to MyLib::A::B.

marceloboeira avatar Feb 16 '16 19:02 marceloboeira

@marceloboeira

Sorry for the delay of response. I had a business trip last week. Thank you for detailed explanation. I understood what had occurred.

Let me ensure: are you using syntastic?

rhysd avatar Feb 21 '16 19:02 rhysd

@rhysd no problem. Yes I'm using it.

marceloboeira avatar Feb 22 '16 01:02 marceloboeira

@marceloboeira

I fixed this in 888bc4a. Could you confirm the latest?

rhysd avatar Feb 22 '16 22:02 rhysd

@rhysd thanks, I'll take a look

marceloboeira avatar Feb 22 '16 23:02 marceloboeira

@marceloboeira ping

rhysd avatar Feb 27 '16 19:02 rhysd

@rhysd sorry, I was busy with some work stuff this week. I just checked here and the problem remains.

marceloboeira avatar Feb 27 '16 22:02 marceloboeira

Sorry, I didn't intend to hurry you up :sweat_drops:

Thank you for the confirmation. Hmm... I'll check it with your reported file structure again.

rhysd avatar Mar 01 '16 07:03 rhysd

@rhysd no worries.

marceloboeira avatar Mar 01 '16 11:03 marceloboeira

I have a similar problem, but it's "already defined constant". Even just a single file with a constant triggers it for me. Up to date on vim-crystal and syntastic http://showterm.io/2c722b79bd5e92090d327

edit: to add that I see "already defined constant"

will avatar Apr 24 '16 05:04 will

I'm seeing this issue today in a Lucky database config file I just brought up. Using Crystal for the first time.

I'm following this tutorial: https://onchain.io/blog/lucky_tutorial

However when I open up config/database.cr I see an error from ALE on the first line. See screenshot ... thanks :)

ps. vim 8.1.2292, using ALE asynchronous checker. Maybe I'll switch back to Syntastic..

Screen Shot 2020-08-26 at 5 06 11 PM

SeanFelipe avatar Aug 27 '20 00:08 SeanFelipe