Fix character array indexing.
authorDavid Anderson <dvander@alliedmods.net>
Sun Aug 05 01:28:12 2012 -0700 (2012-08-05)
changeset 16012807399b953
parent 159 d515dceb12f9
child 161 b3f0aaee735a
Fix character array indexing.
src/SemanticAnalysis.cpp
     1.1 --- a/src/SemanticAnalysis.cpp	Sun Aug 05 01:24:46 2012 -0700
     1.2 +++ b/src/SemanticAnalysis.cpp	Sun Aug 05 01:28:12 2012 -0700
     1.3 @@ -1197,7 +1197,12 @@
     1.4          cc_.reportError(node->left()->pos(), Message_IndexBaseMustBeArray);
     1.5          return;
     1.6      }
     1.7 -    node->setType(left->contained());
     1.8 +
     1.9 +    // Note: char arrays are automatically up-casted to return an int32.
    1.10 +    if (left->isCharArray())
    1.11 +        node->setType(zone_->types()->getPrimitive(PrimitiveType_Int32));
    1.12 +    else
    1.13 +        node->setType(left->contained());
    1.14  }
    1.15  
    1.16  void