Skip to content

Unary + needed to make const optimisation effective #1191

@smartavionics

Description

@smartavionics

Hi, total uglify newbie here so apologies if this is a FAQ/obvious...

I have this declaration in a function:

const rotTol = 5;

and later this use of rotTol (and it's the only use):

if(rot < -rotTol || rot > rotTol)

what it produces is:

const n=5 .... e<-5||e>n? ....

But if I change the source to:

if(rot < -rotTol || rot > +rotTol) // note addition of unary +

the output changes to what I would expect:

e<-5||e>5?

Is this a bug or feature? I am using version 2.6.4.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions