elbywan / crystalline

A Language Server Protocol implementation for Crystal. 🔮
MIT License
436 stars 23 forks source link

Incorrectly reports undefined constants #35

Closed rightbrace closed 2 weeks ago

rightbrace commented 2 years ago

I have an entry file A, which requires B, C, and D. B and C use types from D, but they're always available since A requires them first. This all compiles fine, but crystallline is complaining about undefined constants referenced in B or C from D. What's weird is that it only starts complaining about that when I save B or C, if I save A (even without changes), its fine again. My shard.yml contains:

targets:
  shapes:
    main: src/A

where A is the appropriate filename.

Is this a bug, if not, is there something I can do to force crystalline to do whatever it does when I save A?

nicklatch commented 2 weeks ago

Sorry to revive an old issue, but did you ever find a solution?

elbywan commented 2 weeks ago

This should do the trick:

# shard.yml
crystalline:
  main: src/A.cr

In the original example, I think the issue is that the target name shapes does not match the project folder name. Crystalline is unable to infer that this particular target is the actual entry point to use.