Page 1 of 1

Comment after last command gives error

Posted: Mon Jul 04, 2011 5:47 pm
by Blake
var a integer ;

// Comments after code cause an error.


---
Executing the above in the DBBrowser results in an error:
ERROR: Encountered "var" at line 1, column 1.

Remove the comment and things are ok.

Re: Comment after last command gives error

Posted: Tue Jul 05, 2011 7:31 pm
by Dave
DBrowser, the simple command-line client, uses a crude mechanism to detect whether the user's input is an expression or a statement. If the user's input ends with a semicolon, it's a statement. Otherwise, it's considered an expression. Trivial whitespace is ignored but comments aren't, so DBrowser gets confused.

In short, the comment after the statement makes DBrowser think you've entered an expression, so it tries to evaluate it but 'var' isn't valid in an expression.

I've long meant to fix this, but more important issues have always pushed it down the "to do" list.