# HG changeset patch # User Petter T. # Date 1692437142 -7200 # Sat Aug 19 11:25:42 2023 +0200 # Node ID 4252de882e40930a62d555015f534452acd00a23 # Parent a32f36ccc4c1557fe09c62b08ad7791e52e9a695 VM Fix using WIDE opcode extension for command type calls (bug #64560) E.g. "pi;" would not work if the identifier 'pi' was the 256:th or later identifier in the function, due to forgotten wide slot check. * libinterp/parse-tree/pt-bytecode-vm.cc: Check for slot size, add offset * test/compile/bytecode_misc.m: Update tests diff -r a32f36ccc4c1 -r 4252de882e40 libinterp/parse-tree/pt-bytecode-vm.cc --- a/libinterp/parse-tree/pt-bytecode-vm.cc Fri Aug 18 16:11:47 2023 -0400 +++ b/libinterp/parse-tree/pt-bytecode-vm.cc Sat Aug 19 11:25:42 2023 +0200 @@ -1683,7 +1683,9 @@ // Also skip ip to the end of the opcode. int nargout; bool push_classdef_metas = false; - INSTR opcode = static_cast (*(ip - 2)); + int wide_opcode_offset = slot < 256 ? 0 : -1; // If WIDE is used, we need to look further back + + INSTR opcode = static_cast (*(ip - 2 + wide_opcode_offset)); if (opcode == INSTR::PUSH_SLOT_NARGOUT1 || opcode == INSTR::PUSH_PI) nargout = 1; diff -r a32f36ccc4c1 -r 4252de882e40 test/compile/bytecode_misc.m --- a/test/compile/bytecode_misc.m Fri Aug 18 16:11:47 2023 -0400 +++ b/test/compile/bytecode_misc.m Sat Aug 19 11:25:42 2023 +0200 @@ -111,6 +111,20 @@ assert (s.s == 2); s.w.s = 3; assert (s.w.s == 3); + + % Test command function calling + pi; % WIDE PUSH_PI + assert (round (100 * pi) == 314) + + suby1; + assert (suby1 == 1); + suby2; + [a, b] = suby2; + assert (a == 1) + assert (b == 2) + [a, b] = suby2 (); + assert (a == 1) + assert (b == 2) end @@ -119,3 +133,11 @@ eval (sprintf ("assert (a%03d == %d);", i, i)); end end + +function ret = suby1 + ret = 1; +end + +function [a, b] = suby2 + a = 1; b = 2; +end \ No newline at end of file