Re: Minor bug found in 3.1 and previous

new topic     » goto parent     » topic index » view thread      » older message » newer message

Al Getz wrote:
> 
> --program:
> constant x=1
> x=2
> --end program
> 
> --error message:
> C:\Euphoria\Projects\Test\test.exw:2
> x has not been declared
> x=2
> ^
> 
> Press Enter
> --end message
> 
> 
> Error message should be "May not change the value of a constant",
> or something like that.

Yes, that would be a better message.
You've caught the parser and scanner at an awkward moment.
What's happening here is that you're making the scanner
look up x in the symbol table, when the parser hasn't quite
finished the constant declaration of x. The fact that
you enter a new-line character after constant x = 1
is no more significant than typing a blank, and
the parser needs to see the next scanner token to be sure that
the constant declaration is really finished. You might have
had:
constant x = 1
    + 1  -- x is 2

for instance. Until the parser digests the next token after " = 1",
it can't be sure that the declaration is finished,
and can't record that x is a constant with value 1
in the symbol table.

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu