src/compiler/NameBinding.cpp
changeset 249 82b1f8bc93a9
parent 247 7721042bdb67
child 250 0998a43cc155
     1.1 --- a/src/compiler/NameBinding.cpp	Fri Dec 28 22:47:05 2012 -0800
     1.2 +++ b/src/compiler/NameBinding.cpp	Sat Dec 29 00:12:27 2012 -0800
     1.3 @@ -572,15 +572,16 @@
     1.4  
     1.5              // Do some extra inference based on the initializer, if present.
     1.6              Expression *init = node->initialization();
     1.7 -            if (init &&
     1.8 -                init->isArrayLiteral() &&
     1.9 -                init->toArrayLiteral()->isFixed())
    1.10 -            {
    1.11 -                Local<Type> contained(zone_, type->isArray()
    1.12 -                                             ? ArrayType::cast(type)->contained()
    1.13 -                                             : type);
    1.14 -                if (!inferFixedArrayDimensions(init->toArrayLiteral(), contained, dims, levels))
    1.15 -                    return;
    1.16 +            if (init) {
    1.17 +                if (init->isArrayLiteral() && init->toArrayLiteral()->isFixed()) {
    1.18 +                    Local<Type> contained(zone_, type->isArray()
    1.19 +                                                 ? ArrayType::cast(type)->contained()
    1.20 +                                                 : type);
    1.21 +                    if (!inferFixedArrayDimensions(init->toArrayLiteral(), contained, dims, levels))
    1.22 +                        return;
    1.23 +                } else if (init->isStringLiteral()) {
    1.24 +                    dims[levels - 1] = init->toStringLiteral()->string()->length() + 1;
    1.25 +                }
    1.26              }
    1.27  
    1.28              // If we got extra dimensions, we need to build a new type.