View Issue Details

IDProjectCategoryView StatusLast Update
0035860pas2jstranspilerpublic2020-09-20 02:03
ReporterSimon Ameis Assigned ToMattias Gaertner  
Status assignedResolutionopen 
PlatformDesktop PCOSWindows 7, 64 bit 
Summary0035860: [Optimization] Unreachable code with exit(result); expression
DescriptionThe following code produces javascript code which is not optimal:

function TLoginPage.btnLogin_Click(Event: TJSMouseEvent): Boolean;
  if myvar = '' then
  // do something else

results in

 this.btnLogin_Click = function (Event) {
      var Result = false;
      if (myvar === "") {
        return false;
     // do something else
      return true;
      return Result;

the variable Result is never used by user code and thus could be removed.
Also the return true; leads to unreachable code: return Result;
Additional InformationThis could lead to performance issues if the function is called very often. Otherwise this is only a minor optimization.
TagsNo tags attached.
Fixed in Revision
Attached Files


has duplicate 0037247 resolvedMattias Gaertner Browser console reports "Unreachable code" for functions that only contain an Exit() statement 


Mattias Gaertner

2019-07-19 22:13

manager   ~0117324

I added it to the list
omit implicit "return Result" if last statement is return. issue 35860

Issue History

Date Modified Username Field Change
2019-07-18 18:45 Simon Ameis New Issue
2019-07-19 22:12 Mattias Gaertner Assigned To => Mattias Gaertner
2019-07-19 22:12 Mattias Gaertner Status new => assigned
2019-07-19 22:13 Mattias Gaertner Note Added: 0117324
2020-09-20 02:03 Mattias Gaertner Relationship added has duplicate 0037247