Skip to content

+ function fails with (declare (not constant-fold)) #1

@astlouisf

Description

@astlouisf

The following program

(include "univ-lib/lib.scm")
(declare (not constant-fold))
(+ 1 1)

crash with the error

SyntaxError: Unexpected token ILLEGAL
    gambit_r1 = new Gambit_Flonum(1.val + 1.val);
                                  ^^
SyntaxError: Unexpected token ILLEGAL

when compiled with gsc -c -target js program-name.scm

The same problem arises with -target equals to python and php. I could not assess if ruby is also victim of this bug (it crashed on what seemed to be another bug).

The error seems to be that + gets inlined, which generate a test case for when its operands are flonums. This generate an attribute access which is not allowed on fixnums by the syntax of the target languages (Ruby might be immune to this bug because "everything is an object").

Note: The code should work when both -repr-flonumand -repr-fixnum are set to class (I didn't tested it though)

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