Strange error msg

I got this:

Syntax error in own_20.cr:51: expecting token ‘CONST’, not ‘uiButton’
class uiButton < Object
^

disappeared when I changed char-case to : UiButton
the Error message is very strange and unrelated though …

All types/class names begin with a capital letter. The error is saying it was expecting a CONST not uiButton meaning you should be passing something that starts with a capital letter.

1 Like

thanks.

another:
“Syntax error in myfile.cr:118: can’t define def inside def”
(this actually was caused by forgetting the “end” of an “if” clause)

the point is: those messages do not-at-all help to find/solve the issue.
so why not just give a quote of shakespear instead ? |irony|

But would Crystal actually know it if it was really the end of a function? You defined a function, put an if block inside it, and end means end of if. Then, you define another function, but your other function wasn’t closed because the end just closed the if. :wink: (And Crystal doesn’t allow nested functions, unlike Ruby.) In the end, something didn’t get closed.

The compiler stopped when it found its first error, so it didn’t find the other one.

Hope this makes it clearer. :slight_smile: