Have I hit compiler bugs?

The proof-of-concept crystal tool undefined detected the undefined method in the case in question.

a.cr

# UNEXPECTED -- compiles even though bar is not defined
def foo(user : NamedTuple?)
  bar(user.not_nil![:id]?)
end

# UNEXPECTED -- compiles even though bar is not defined
def foo(user : Tuple?)
  bar(user.not_nil![0]?)
end

# UNEXPECTED -- compiles even though bar nor quux is defined
def foo(user : Hash(String,String)?)
  bar(user.not_nil!.quux)
end

foo(nil)

crystal tool undefined a.cr

a.cr:3:3	bar	1 lines
a.cr:8:3	bar	1 lines
a.cr:13:3	bar	1 lines
a.cr:13:7	quux	1 lines

Most of Crystal’s build time is spent in LLVM.

image

Semantic does not take much time. The data passed to LLVM must be pruned, but checking for undefined methods during pruning may not be as costly as it seems.


At this point, I do not yet have the expertise to fully understand the code generated by AI, which prevents me from contributing a pull request to the Crystal Repository.Understanding and utilizing AI output requires extensive knowledge and experience. As AI performance improves, there may be a paradox that experts will become necessary rather than unnecessary :thinking:

2 Likes