Page MenuHomeFeedback Tracker

Fault in the EnScript compiler for consts
New, NormalPublic

Description

When a const variable is defined as a sum of another variable and a literal, it gets evaluated as 0 when accessed by a primitive operator.

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Operating System Version
1809 Build 17763.134
Category
Scripting
Steps To Reproduce

const int OFFSET = 10;
const int VAR = OFFSET+1;

Print(OFFSET); Will return 10
Print(OFFSET+1);
Will return 11
Print(VAR); Will return 11
Print(VAR+1);
Will return 1!!!!!

Additional Information

When the access is deferred to a function this error is avoided.

int Add(int num1, int num2) { return num1+num2; }
Print( Add( VAR, 1 ) ); //Will now return 12 as expected

Routing access through a wrapper also mitigates the issue.

int Passthrough(int num) { return num; }
Print( Passthrough( VAR ) + 1 ); //Will also return 12 as expected

Event Timeline

namco-4 created this task.Nov 25 2018, 7:33 PM