Euphoria Ticket #730: Bad translation of sequence arithmetic

The following causes a crash when translated:

without inline 
function bar() 
	sequence s = {1,2,3} + 1 
	return s[1] 
end function 
? bar() 

For some reason, the translator assumes that s should be an integer, and translates as follows:

    /** 	sequence s = {1,2,3} + 1*/ 
    { // coercing _s_142 to an integer 1 
        _s_142 = binary_op(PLUS, 1, _10); 
        if( !IS_ATOM_INT(_s_142) ){ 
            _s_142 = (object)DBL_PTR(_s_142)->dbl; 
        } 
    } 
The IL disassembly shows that a PLUS1 op is emitted.
     3: 093 145 0 142                    # PLUS1: [LIT {1,2,3}:145] + 1 => [s:142] 
Other PLUS ops might also be affected. When the code is inlined into the top level, it translates correctly. The problem may be with BB value tracking in the translator.

Details

Type: Bug Report Severity: Blocking Category: Translator
Assigned To: mattlewis Status: Fixed Reported Release: 4.0.3
Fixed in SVN #: View VCS: none Milestone: 4.0.4

1. Comment by mattlewis Nov 30, 2011

See: hg:euphoria/rev/73cf3d110e2f

changeset: 5290:73cf3d110e2f branch: 4.0 parent: 5286:5062bba3b0dc user: Matt Lewis date: Wed Nov 30 17:32:26 2011 -0500 files: docs/release/4.0.4.txt source/c_decl.e tests/t_math.e description:

  • do not initialize private variables to TYPE_INTEGER as start of translated routine
  • fixes ticket 730

Search



Quick Links

User menu

Not signed in.

Misc Menu