Ignore the index when accessing a scalar variable

This commit is contained in:
Noisyfox 2025-09-29 23:34:26 +08:00
parent d4273b4f70
commit ef0748e96b

View file

@ -1011,10 +1011,10 @@ namespace client
OptWithPos &output)
{
if (! ctx->skipping()) {
if (! opt.opt->is_vector())
ctx->throw_exception("Cannot index a scalar variable", opt.it_range);
if (index < 0)
index = 0; // Orca: fallback to first element if index < 0, this matches the behavior of BambuStudio
if (!opt.opt->is_vector())
index = -1; // Orca: ignore the index if variable is scalar, this matches the behavior of BambuStudio
output = opt;
output.index = index;
} else