Project

General

Profile

Support #1759

Better error mesg for 1.2.3.4?

Added by John Abbott 9 months ago. Updated about 1 month ago.

Status:
New
Priority:
Low
Assignee:
-
Category:
Parser/Interpreter
Target version:
Start date:
03 Aug 2023
Due date:
% Done:

0%

Estimated time:
Spent time:

Description

I mistyped and obtained an error message which could be better:

/**/ [1.2.3.4];
--> ERROR: I was expecting an identifier but I've found the number "3.4" 
--> [1.2.3.4];
-->      ^^^

History

#1 Updated by John Abbott 9 months ago

Maybe try some other similar wrong inputs? 1.2. or 1.2.3 or even 1.2.3.4.5

#2 Updated by John Abbott 9 months ago

Here is the current state:

/**/ 1.2.
[[waiting for semicolon]] /**/ ;
--> ERROR: I was expecting an identifier but I've found the operator/symbol ";" 
--> ;
--> ^
/**/ 1.2.3
--> ERROR: I was expecting an identifier but I've found the number "3" 
--> 1.2.3
-->     ^
/**/ 1.2.3.
--> ERROR: I was expecting an identifier but I've found the number "3" 
--> 1.2.3.
-->     ^
/**/ 1.2.3.4
--> ERROR: I was expecting an identifier but I've found the number "3.4" 
--> 1.2.3.4
-->     ^^^
/**/ 1.2.3.4.
--> ERROR: I was expecting an identifier but I've found the number "3.4" 
--> 1.2.3.4.
-->     ^^^
/**/ 1.2.3.4.5
--> ERROR: I was expecting an identifier but I've found the number "3.4" 
--> 1.2.3.4.5
-->     ^^^

Also

/**/ 1.
[[waiting for semicolon]] /**/ ;
--> ERROR: I was expecting an identifier but I've found the operator/symbol ";" 
--> ;
--> ^

#3 Updated by John Abbott about 1 month ago

  • Target version changed from CoCoA-5.4.2 to CoCoA-5.4.4

#4 Updated by John Abbott about 1 month ago

The relevant source code is probably in Parser.C near line 1924 inside the function parseSelectors right after case TT_DOT:

Is it really worth trying to handle this case? I do sometimes mistakenly type a dot instead of a comma, and it is not always so obvious that I have mistyped... A friendlier error message would be nice, but may be complicated to achieve. Maybe we should just document somewhere(??) that an unhelpful error message may arise when a comma is mistyped as a dot...? How about

a := 123;
L := [a. 2]; // where I *thought* I had typed a comma

Again we get ERROR: I was expecting an identifier...

Also available in: Atom PDF