Skip to content

Trouble passing "true", "false" and "null" #585

@fabiosantoscode

Description

@fabiosantoscode

Some values can't be passed directly to a function.

I was trying to pass true as the first argument to a function, but it got turned into undefined. From what I've seen this happens with false and null as well.

Check the below example and its output (from running ./v7 file.js), written in the comments:

'use strict'

function fn(a, b) { print("a: " + a + ", b: " + b) }

fn(3, 2) // a: 3, b: 2 
fn(true) // a: undefined, b: undefined 
fn(true, true) // a: true, b: undefined 
fn(true, "foo") // a: true, b: foo 

If instead you put the true value in a variable and pass it through that variable, everything works well.

print('-- from a variable')
var trueVar = true

fn(trueVar) // a: true, b: undefined 
fn(trueVar, trueVar) // a: true, b: true 
fn(trueVar, "foo") // a: true, b: foo 

Everything works if true is generated from any expression as well.

I compiled the latest master (as of today) of v7 with the following command:

gcc -O0 -DV7_EXE -DV7_ENABLE_STACK_TRACKING -DV7_ENABLE_FILE v7.c -lm

But even when keeping only -DV7_EXE I can still reproduce this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions