From 9de7ba28708977d4a6c6b91a439155927cf17d0b Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 24 Feb 2012 14:26:11 -0500 Subject: [PATCH] typing: error on foo() when foo is a variable With the last parser modification we can now distinguish between no arguments and empty parentheses. Signed-off-by: Jean Privat --- src/syntax/typing.nit | 2 +- tests/error_var_args3.nit | 18 ++++++++++++++++++ tests/error_var_args4.nit | 18 ++++++++++++++++++ tests/sav/error_var_args3.sav | 1 + tests/sav/error_var_args4.sav | 1 + 5 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/error_var_args3.nit create mode 100644 tests/error_var_args4.nit create mode 100644 tests/sav/error_var_args3.sav create mode 100644 tests/sav/error_var_args4.sav diff --git a/src/syntax/typing.nit b/src/syntax/typing.nit index 4155ecc..0fb3def 100644 --- a/src/syntax/typing.nit +++ b/src/syntax/typing.nit @@ -1849,7 +1849,7 @@ redef class ACallFormExpr n = new AClosureCallExpr.init_aclosurecallexpr(n_id, n_args, n_closure_defs) n._variable = variable else - if not n_args.n_exprs.is_empty then + if not n_args.n_exprs.is_empty or n_args isa AParExprs then v.error(self, "Error: {name} is variable, not a function.") return end diff --git a/tests/error_var_args3.nit b/tests/error_var_args3.nit new file mode 100644 index 0000000..b93b55e --- /dev/null +++ b/tests/error_var_args3.nit @@ -0,0 +1,18 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2004-2008 Jean Privat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +var t: Int +t() diff --git a/tests/error_var_args4.nit b/tests/error_var_args4.nit new file mode 100644 index 0000000..b16f971 --- /dev/null +++ b/tests/error_var_args4.nit @@ -0,0 +1,18 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Copyright 2004-2008 Jean Privat +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +var t: Int +t() = 12 diff --git a/tests/sav/error_var_args3.sav b/tests/sav/error_var_args3.sav new file mode 100644 index 0000000..1683b26 --- /dev/null +++ b/tests/sav/error_var_args3.sav @@ -0,0 +1 @@ +error_var_args3.nit:18,1--3: Error: t is variable, not a function. diff --git a/tests/sav/error_var_args4.sav b/tests/sav/error_var_args4.sav new file mode 100644 index 0000000..a3329e7 --- /dev/null +++ b/tests/sav/error_var_args4.sav @@ -0,0 +1 @@ +error_var_args4.nit:18,1--8: Error: t is variable, not a function. -- 1.7.9.5