tranleduy2000 / pascalnide

Pascal Compiler for Android
91 stars 25 forks source link

Error #31

Open Userhunt opened 6 years ago

Userhunt commented 6 years ago

Program p; var a, b:integer; Begin readln(a); if (a=0) or (a=1) then else writeln('error'); writeln(a); end.

error - If a=0 then "the program should not do anything" else "the program should write error"

smaslovski commented 6 years ago

It is not a bug. You must use a ";" after "then" as an indication of no-op.

Program p; var a, b:integer; Begin readln(a); if (a=0) or (a=1) then ; else writeln('error'); writeln(a); end.

smaslovski commented 6 years ago

By the way, I was wrong in my last comment: "if false then else S;" where S is any statement is valid syntax in Pascal. And "if false then ; else S;" is invalid. So, it IS a bug. Actually, the application treats semicolons (;) in a very inconsistent way, as i just saw...