[vala/0.34] vala: Don't transform an explicit "null" into a valid format-string
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.34] vala: Don't transform an explicit "null" into a valid format-string
- Date: Sat, 9 Dec 2017 13:42:09 +0000 (UTC)
commit b75538ab4e1ab68b87f1d0bb3827c984adff6bd2
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Dec 6 16:11:10 2017 +0100
vala: Don't transform an explicit "null" into a valid format-string
https://bugzilla.gnome.org/show_bug.cgi?id=791215
tests/Makefile.am | 1 +
tests/methods/bug791215.vala | 8 ++++++++
vala/valamethodcall.vala | 4 +++-
3 files changed, 12 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8befbd1..5a42d51 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -77,6 +77,7 @@ TESTS = \
methods/bug737222.vala \
methods/bug743877.vala \
methods/bug771964.vala \
+ methods/bug791215.vala \
methods/generics.vala \
control-flow/break.vala \
control-flow/expressions-conditional.vala \
diff --git a/tests/methods/bug791215.vala b/tests/methods/bug791215.vala
new file mode 100644
index 0000000..b5e0c09
--- /dev/null
+++ b/tests/methods/bug791215.vala
@@ -0,0 +1,8 @@
+[PrintfFormat]
+void foo_print (string? fmt, ...) {
+ assert (fmt == null);
+}
+
+void main () {
+ foo_print (null);
+}
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 720b81c..68b689b 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -420,7 +420,9 @@ public class Vala.MethodCall : Expression {
// printf arguments
if (mtype is MethodType && ((MethodType) mtype).method_symbol.printf_format) {
StringLiteral format_literal = null;
- if (last_arg != null) {
+ if (last_arg is NullLiteral) {
+ // do not replace explicit null
+ } else if (last_arg != null) {
// use last argument as format string
format_literal = last_arg as StringLiteral;
if (format_literal == null && args.size == params.size - 1) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]