]> git.ipfire.org Git - thirdparty/vala.git/commit
vala: Add support for null-safe access operator
authorJeremy Philippe <jeremy.philippe@gmail.com>
Wed, 18 Dec 2019 15:54:05 +0000 (16:54 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 6 Aug 2021 14:40:21 +0000 (16:40 +0200)
commit9572175213c300e50476835fe1201ff4b040ec36
tree37197033d4433b4b15e4faef08bd32fffa5ec00d
parent453c81d3844ec7ea8ec8dfbcd52346e2c3a24cf7
vala: Add support for null-safe access operator

This implements support for the "null-safe" operator of C#
(also called "safe navigation" operator).

  var foo = bar?.foo;
  var foo = bar?.foo();
  var foo = bar?[3];
  var foo = bar?[1:2];

It applies to plain member access, method calls, element access and
slice expressions (including void method calls, which are simply bypassed
if the inner expression is null).

Fixes https://gitlab.gnome.org/GNOME/vala/issues/522
12 files changed:
tests/Makefile.am
tests/control-flow/bug761267-1.c-expected [new file with mode: 0644]
tests/control-flow/bug761267-1.vala [new file with mode: 0644]
tests/control-flow/bug761267-2.c-expected [new file with mode: 0644]
tests/control-flow/bug761267-2.vala [new file with mode: 0644]
tests/control-flow/bug761267-3.test [new file with mode: 0644]
vala/valaelementaccess.vala
vala/valaexpression.vala
vala/valamemberaccess.vala
vala/valamethodcall.vala
vala/valaparser.vala
vala/valasliceexpression.vala