Hello nimmers!

Below you'll find a nim program that contains syntax errors.

**Quiz 1** : How many errors can you detect just by looking at the code?

**Bonus Question** : One of lines crashes the compiler (as of 0.18). Can you 
detect it?
    
    
    type MyTuple = tuple(a: int, b: int)
    
    var myTuple: MyTuple = [a: 10, b: 10]
    
    type MyObject = ref Object
      a: int
    
    var myObject: MyObject = MyObject(a = 5)
    
    type MySpecialObject = ref object of MyObject
    
    var seqOfStrings: seq[int] = @[int]
    
    proc silentProc()* = discard
    
    proc inc(var a: int) = a += 1
    

**Quiz 2** : Now, imagine that you are a nim newbie. Try to fix the errors with 
the help of nim manual and compiler error messages. Or,better yet, ask a nim 
beginner to fix the code and watch the frustration grow.

The errors in the code were not invented by hand, they are real mistakes I 
admit I have made when learning to nim. Therefore I expect that other beginners 
will make the same mistakes. The point is that the compiler error messages for 
these examples are not only unhelpful, they are misleading - if you blindly 
follow them, you'll end up with even more confusion.

As someone who is currently heavily investing in nim, I hope that the user base 
will grow and the language will prosper. I see development of better syntax 
error messages as one of the high priority tasks in order to make nim more 
beginner-friendly. I'm namely worried that scary and misleading error messages 
will intimidate some newbies away from nim before they start to see the light. 
But the current semantically oriented error messages are very helpful for more 
seasoned programmers, so let's not loose them. Instead, I propose that there 
should be a separate syntax error detection phase in compiler pipeline that 
could identify common syntax errors and give helpful quick fix suggestions.

**Quiz 3** : Do you know other "easily made" syntax errors that produce 
misleading error messages? Help nim newbies by publishing your cautionary 
example here (or somewhere).

Happy nimming!

Reply via email to