Problem with Optimize javascript output

Just starting out? Need help? Post your questions and find answers here.
User avatar
Paul
Posts: 197
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Problem with Optimize javascript output

Post by Paul »

I have some code that compiles and runs fine but if I select "Optimize javascript output" under Compiler Options I receive an error and it will not compile...

Code: Select all

spiderbasic.js:522: WARNING - unreachable code
return 0;
^

spiderbasic.js:540: WARNING - unreachable code
return "";
^
...

Picked up _JAVA_OPTIONS: -Xmx512M
What would cause this and what should I be looking for to fix it?
(sorry I cannot post the source code)
User avatar
Peter
Posts: 1093
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: Problem with Optimize javascript output

Post by Peter »

@Paul:

This is the output of a JavaScript linter.

For explanation:

The SB-Procedure:

Code: Select all

Procedure TestProc()
EndProcedure
is converted to

Code: Select all

function f_testproc() {
return 0;
}
(note the return 0)


The SB-Procedure:

Code: Select all

Procedure TestProc()
  ProcedureReturn 42
EndProcedure
is converted to

Code: Select all

function f_testproc() {
if (1) return 42;
return 0;
}
Here, return 0 is unreachable because of return 42

However, this is only a warning and should not interrupt the compile process.
Paul wrote:what should I be looking for to fix it?
do not use the Optimizer until further notice. ;)

Greetings ... Peter
User avatar
DanLJr
Posts: 58
Joined: Wed Jul 04, 2018 4:24 am
Location: USA

Re: Problem with Optimize javascript output

Post by DanLJr »

Any update? It's been another half a year and I'm doing some product release work now, and running into this problem myself all of a sudden. (It JUST started happening since I added some File Requester stuff that uses callbacks. Mostly right from the samples in the help file, and now after a year of working fine, stuff won't optimize. Same kind of error.) There's GOT to be a work-around... It's actually kind of important that I successfully optimize the JS for one particular project.

Please help!
-Dan
Peter wrote:@Paul:

This is the output of a JavaScript linter.

For explanation:

The SB-Procedure:

Code: Select all

Procedure TestProc()
EndProcedure
is converted to

Code: Select all

function f_testproc() {
return 0;
}
(note the return 0)


The SB-Procedure:

Code: Select all

Procedure TestProc()
  ProcedureReturn 42
EndProcedure
is converted to

Code: Select all

function f_testproc() {
if (1) return 42;
return 0;
}
Here, return 0 is unreachable because of return 42

However, this is only a warning and should not interrupt the compile process.
Paul wrote:what should I be looking for to fix it?
do not use the Optimizer until further notice. ;)

Greetings ... Peter
-Dan L.
:: falling on my face a lot lately; learning even more because of it! ::
Post Reply