From 222ace933f0f8d12fc60b7843acf82274e2ed2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 30 Oct 2026 15:20:09 -0400 Subject: [PATCH 1/2] nitx: don't try to execute a command marked as error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Have nitx safely stop a command before executing one marked as an error, preventing later failures. A few of the commands assume they are valid and use `mproperty.as(not null)` which fails when invalid. Signed-off-by: Alexis Laferrière --- src/doc/term/term.nit | 2 +- tests/nitx.args | 1 + tests/sav/nitx_args4.res | 4 ++++ 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 tests/sav/nitx_args4.res diff --git a/src/doc/term/term.nit b/src/doc/term/term.nit index 7d490e44d5..a909d232a4 100644 --- a/src/doc/term/term.nit +++ b/src/doc/term/term.nit @@ -36,7 +36,7 @@ redef class CommandParser error.print_message(no_color) print "" end - if cmd == null then return + if cmd == null or error isa CmdError then return cmd.execute(no_color) end end diff --git a/tests/nitx.args b/tests/nitx.args index 3bc599de25..74b0440543 100644 --- a/tests/nitx.args +++ b/tests/nitx.args @@ -1,3 +1,4 @@ base_simple3.nit -c A --no-color base_simple3.nit -c foo --no-color base_simple3.nit -c "defs: base_simple3::base_simple3" --no-color +base_simple3.nit -c "lin: NotAnEntity" --no-color diff --git a/tests/sav/nitx_args4.res b/tests/sav/nitx_args4.res new file mode 100644 index 0000000000..c6ea93362c --- /dev/null +++ b/tests/sav/nitx_args4.res @@ -0,0 +1,4 @@ + +No result found for `NotAnEntity`... + + From 0f44918d91f5a10d0d729c276e88d11b1d3e6cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20Laferri=C3=A8re?= Date: Fri, 30 Oct 2026 15:20:09 -0400 Subject: [PATCH 2/2] nitx: skip expressions without an associated call site MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The nitx command `call:` visits every `ASendExpr` under each property and reads its callsite. It would fail on the arguments of annotations which are stored as `ASendExpr` in the AST even thought they aren't real calls and thus don't have a call site. Signed-off-by: Alexis Laferrière --- src/doc/commands/commands_usage.nit | 4 +++- tests/nitx.args | 1 + tests/nitx_annotation_args.nit | 30 +++++++++++++++++++++++++++++ tests/sav/nitx_args5.res | 8 ++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 tests/nitx_annotation_args.nit create mode 100644 tests/sav/nitx_args5.res diff --git a/src/doc/commands/commands_usage.nit b/src/doc/commands/commands_usage.nit index 82e26ee18f..701343f93b 100644 --- a/src/doc/commands/commands_usage.nit +++ b/src/doc/commands/commands_usage.nit @@ -199,7 +199,9 @@ private class MPropertyCallVisitor do node.visit_all(self) if not node isa ASendExpr then return - calls.add node.callsite.as(not null).mproperty + var callsite = node.callsite + if callsite == null then return + calls.add callsite.mproperty end end diff --git a/tests/nitx.args b/tests/nitx.args index 74b0440543..3ec9c57fc0 100644 --- a/tests/nitx.args +++ b/tests/nitx.args @@ -2,3 +2,4 @@ base_simple3.nit -c A --no-color base_simple3.nit -c foo --no-color base_simple3.nit -c "defs: base_simple3::base_simple3" --no-color base_simple3.nit -c "lin: NotAnEntity" --no-color +nitx_annotation_args.nit -I ../lib/core -c "call: nitx_annotation_args::A::foo" --no-color diff --git a/tests/nitx_annotation_args.nit b/tests/nitx_annotation_args.nit new file mode 100644 index 0000000000..cb73688264 --- /dev/null +++ b/tests/nitx_annotation_args.nit @@ -0,0 +1,30 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# 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. + +module nitx_annotation_args + +import kernel + +class A + autoinit y + + var x = 0 is writable(set_x) + + var y: Int + + fun foo do end +end + +var a = new A(1) +a.foo diff --git a/tests/sav/nitx_args5.res b/tests/sav/nitx_args5.res new file mode 100644 index 0000000000..2602b1024e --- /dev/null +++ b/tests/sav/nitx_args5.res @@ -0,0 +1,8 @@ + +Methods calling `nitx_annotation_args::A::foo`: + + * nitx_annotation_args::nitx_annotation_args$core::Sys$main + # The main method of a program. + redef fun main + nitx_annotation_args.nit:29,1--30,5 +