View Issue Details

IDProjectCategoryView StatusLast Update
0037247pas2jstranspilerpublic2020-09-11 10:52
ReporterSven Barth Assigned To 
Status newResolutionopen 
Product Versiontrunk 
Summary0037247: Browser console reports "Unreachable code" for functions that only contain an Exit() statement
DescriptionWhen a function only contains an Exit() statement the browser's console (at least in Firefox) reports "Unreachable code" due to the translation of the Exit statement being followed by a "return Result".
Steps To ReproduceCompile the attached example and open test.html inside a browser.
Additional InformationI noticed this when using Generics.Collections.TList<>. The TEnumerator<>.MoveNext contains such a construct which makes using it rather verbose inside the browser. So if this can't be solved right now it might be a good idea to fix TEnumerator<>.MoveNext as well as TEnumerable<>.GetEnumerator.
TagsNo tags attached.
Fixed in Revision
Attached Files


Sven Barth

2020-06-24 10:00


test.html (238 bytes)   
    <meta charset="utf-8"/>
    <script type="application/javascript" src="tunreachable3.js"></script>
    <script type="application/javascript">;
test.html (238 bytes)   
tunreachable3.pp (128 bytes)   
program tunreachable3;

{$mode objfpc}

function Test: Integer;

tunreachable3.pp (128 bytes)   

Michael Van Canneyt

2020-06-24 10:32

administrator   ~0123543

Mattias will need to look at the exit() thing.
Meanwhile I changed the generics code so it uses exit less; In particular the situations you refer to. Revision 778.

Sven Barth

2020-06-24 13:34

developer   ~0123554

Thank you so far. At least this results in much more quiet sessions now. :)

Simon Ameis

2020-09-11 10:52

reporter   ~0125475

This might be a duplicate of 0035860.

Issue History

Date Modified Username Field Change
2020-06-24 10:00 Sven Barth New Issue
2020-06-24 10:00 Sven Barth File Added: test.html
2020-06-24 10:00 Sven Barth File Added: tunreachable3.pp
2020-06-24 10:32 Michael Van Canneyt Note Added: 0123543
2020-06-24 13:34 Sven Barth Note Added: 0123554
2020-09-11 10:52 Simon Ameis Note Added: 0125475