Closed Bug 706399 Opened 13 years ago Closed 13 years ago

[ASC BUG] ASC strict mode rejects automatic widening for - * / %

Categories

(Tamarin Graveyard :: Tools, defect, P2)

defect

Tracking

(Not tracked)

VERIFIED FIXED
Q2 12 - Cyril

People

(Reporter: lhansen, Assigned: lhansen)

References

Details

Test case:

package {
  var foo:float4 = new float4(2f);
  var bar:float4 = foo * 4f;
}

Compile with -strict -AS3 -abcfuture.  We get an error:

[Compiler] Error #1067: Implicit coercion of a value of type float4 to an
   unrelated type Number.
   ../asc.as, Ln 3, Col 19: 
   	var bar:float4 = foo * 4f;
   ..................^

Changing 4f to float4(4f) makes the error go away.

The error is not signaled for the "+" operator, but it is signaled for other binary operators.

The float4 spec does not require an error here, nor should it - the automatic widening to float4 is non-lossy.

As an aside the compiler should really perform the widening at compile time.  It doesn't.  It's an interesting corner case of the constant evaluation spec whether available type information should be used to drive compile-time widening of constants.

(If foo is a const then constant evaluation is performed correctly though.)
Actually not a blocker for the first release since it has an easy workaround, by wrapping float4() around 4f.
Priority: P1 → P3
Sufficiently annoying to be -> P2.
Priority: P3 → P2
Clearly one or more problems in ConstantEvaluator.java: evaluate(Context,BinaryExpressionNode).

First, the cases for - * / % test for "lhs is float4 AND rhs is float4" but should use "OR".

Second, the type tests do not actually trigger as they're supposed to, it may be that types cannot be compared using == in the manner here, though it's certainly done for other types in code that looks older.
Assignee: nobody → lhansen
changeset:   78:fcbc9c325af9
tag:         tip
user:        Lars T Hansen <lhansen@adobe.com>
date:        Tue Dec 06 15:54:36 2011 +0100
summary:     Fix several bugs (unavailable atm due to bugzilla downage), dealing with comparison with undefined and mixed math with float4 as one operand, all in strict mode.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
This was blocking the conversion of the Float4 tests to be compiled in strict mode. That has now been completed and working as of:

changeset:   7057:ca6997209c5a
user:        Brent Baker <brbaker@adobe.com>
date:        Fri Dec 09 09:17:18 2011 -0500
summary:     Convert all float4 test media to compile and run with -strict
Status: RESOLVED → VERIFIED
Flags: in-testsuite+
Flags: flashplayer-triage+
Flags: flashplayer-qrb+
Flags: flashplayer-bug-
You need to log in before you can comment on or make changes to this bug.