Multiple declarations

# Michael O'Brien (17 years ago)

Is the following valid?

var x = 2 var x = 3

The ES4 RI prevents this. ASC redefines x.

What should this do?

Michael

# Jeff Dyer (17 years ago)

Works for me in the RI:

var x = 10; var x = 20; print(x) 20

As it should.

# Graydon Hoare (17 years ago)

Jeff Dyer wrote:

Works for me in the RI:

var x = 10; var x = 20; print(x) 20

As it should.

Could be an old build? Check one of the snapshots.

buildbot.ecmascript.org/es4/waterfall

# Michael O'Brien (17 years ago)

Thanks - a new build fixed it.

Michael

# Michael O'Brien (17 years ago)

Follow up:

The RI allows typed redeclarations providing the type is not double.
This works:

// var x:double = 7 // delete x

var x:boolean = true delete x

var x:string = "there" delete x

var x:boolean = false delete x

var x = false delete x

But uncomment the first declaration and you get:

defining ... ERROR FixtureError: incompatible redefinition of fixture name: x
(near t.as:1:1-1.3)

I presume this is an RI bug?

Michael

# Lars Hansen (17 years ago)

Should be a bug. The rule that's been considered is that redefinition is allowed if the annotations are equal (either missing or the same type).