I am facing a strange issue with variable declaration in nim. The program is like this.
var
cStatus_P,c_GEN: int
cGen = 13;
cStatus_P = 14;
echo c_gen
When I run this program, no error is thrown for cGen not being declared but cGEN is using the value of c_GEN.
nim c --w:on --opt:speed --d:release --hints:off --passC:-ffast-math --mm:orc -r "Var_Decl_Test.nim" (in directory: E:\Work\IFRS17\CreditAccess\Mar_25\Workbook)
13
Compilation finished successfully.
Nim identifiers explicitly ignore underscores and case for anything other than the first character. This is a basic feature of the language. c_GEN == c_gen == cGen == cgen == c_G_e_N
https://nim-lang.org/docs/manual.html#lexical-analysis-identifier-equality
I don't think so.
What you can do is to pass --styleCheck:usages --styleCheck:hint, and then the compiler will complain when you use a symbol with the incorrect name.
Yes, that's what I meant.
If you want to stop execution, you can use styleCheck:error too. Personally I prefer hints so that a new compiler version won't break compilation outright if it changes in what it's reporting (which has happened before). But I guess that's only relevant if you want to support multiple compiler versions.