basic-types/arrays-fixed-assignment.vala \
basic-types/array-uint8-uchar-compat.vala \
basic-types/pointers.vala \
+ basic-types/pointers-arithmetic.vala \
basic-types/sizeof.vala \
basic-types/garray.vala \
basic-types/glists.vala \
nullability/member-access-nullable-instance.test \
nullability/method-parameter-invalid-convert.test \
nullability/method-return-invalid-convert.test \
+ nullability/string-concat.test \
$(NULL)
LINUX_TESTS = \
--- /dev/null
+void test_chars () {
+ char* s = "foo";
+ char* begin = s;
+ char* end = begin + 2;
+
+ assert (begin[0] == 'f');
+ assert (end[0] == 'o');
+}
+
+void test_strings () {
+ string s = "foo";
+ string* begin = s;
+ string* end = begin + s.length - 1;
+
+ assert (((char*) begin)[0] == 'f');
+ assert (((char*) end)[0] == 'o');
+}
+
+void main () {
+ test_chars ();
+ test_strings ();
+}
--- /dev/null
+Invalid Code
+
+void main () {
+ string? foo = null;
+ string bar = foo + "bar";
+}
right.target_type = right.value_type.copy ();
right.target_type.value_owned = false;
- if (left.value_type.data_type == context.analyzer.string_type.data_type
- && operator == BinaryOperator.PLUS) {
+ if (operator == BinaryOperator.PLUS && !(left.value_type is PointerType)
+ && left.value_type.compatible (context.analyzer.string_type)) {
// string concatenation
- if (right.value_type == null || right.value_type.data_type != context.analyzer.string_type.data_type) {
+ if (right.value_type == null || !right.value_type.compatible (context.analyzer.string_type)) {
error = true;
Report.error (source_reference, "Operands must be strings");
return false;