basic-types/custom-types.vala \
basic-types/default-gtype.vala \
basic-types/strings.vala \
+ basic-types/string-concat-null.test \
basic-types/arrays.vala \
basic-types/arrays-generics.vala \
basic-types/arrays-fixed-assignment.vala \
--- /dev/null
+Invalid Code
+
+void main () {
+ var str = "foo" + null + "bar";
+}
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
VALA_EXTERN void test_string (void);
+VALA_EXTERN void test_string_concat (void);
VALA_EXTERN void test_string_joinv (void);
VALA_EXTERN void test_string_printf (void);
VALA_EXTERN void test_string_replace (void);
_g_free0 (s);
}
+void
+test_string_concat (void)
+{
+ gchar* s = NULL;
+ gchar* _tmp0_;
+ _tmp0_ = g_strdup ("hello" "world");
+ s = _tmp0_;
+ _vala_assert (g_strcmp0 (s, "helloworld") == 0, "s == \"helloworld\"");
+ _g_free0 (s);
+}
+
static gchar*
_vala_g_strjoinv (const gchar* separator,
gchar** str_array,
_vala_main (void)
{
test_string ();
+ test_string_concat ();
test_string_joinv ();
test_string_printf ();
test_string_replace ();
assert (t == s);
}
+void test_string_concat () {
+ var s = "hello" + "world";
+ assert (s == "helloworld");
+}
+
void test_string_joinv () {
string[] sa = { "hello", "my", "world" };
void main () {
test_string ();
+ test_string_concat ();
test_string_joinv ();
test_string_printf ();
test_string_replace ();
&& left.value_type.compatible (context.analyzer.string_type)) {
// string concatenation
- if (right.value_type == null || !right.value_type.compatible (context.analyzer.string_type)) {
+ if (right.value_type == null || !right.value_type.compatible (context.analyzer.string_type)
+ || left is NullLiteral || right is NullLiteral) {
+ // operands cannot be null
error = true;
Report.error (source_reference, "Operands must be strings");
return false;