From 95582fbabd054d0b2ea323539b4023c0f9bd4fb5 Mon Sep 17 00:00:00 2001 From: Filip Krikava Date: Fri, 21 Jun 2024 11:45:54 +0200 Subject: [PATCH] Fix calling XLENGTH on S4SXP (fixes #1289) --- rir/src/interpreter/interp.cpp | 3 ++- rir/src/runtime/TypeFeedback.h | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rir/src/interpreter/interp.cpp b/rir/src/interpreter/interp.cpp index 0ac48a676..e6086d574 100644 --- a/rir/src/interpreter/interp.cpp +++ b/rir/src/interpreter/interp.cpp @@ -3590,7 +3590,8 @@ SEXP evalRirCode(Code* c, SEXP env, const CallContext* callCtxt, (valT == REALSXP || valT == INTSXP)) || // 2 (vectorT == INTSXP && valT == INTSXP) || (vectorT == VECSXP && val != R_NilValue)) && - (XLENGTH(val) == 1 || vectorT == VECSXP)) { // 3 + ((valT != S4SXP && XLENGTH(val) == 1) || + vectorT == VECSXP)) { // 3 int idx_ = -1; diff --git a/rir/src/runtime/TypeFeedback.h b/rir/src/runtime/TypeFeedback.h index b77e5f6e7..9cc347b33 100644 --- a/rir/src/runtime/TypeFeedback.h +++ b/rir/src/runtime/TypeFeedback.h @@ -188,7 +188,7 @@ struct ObservedValues { // > .Internal(inspect(mf[["x"]])) // @56546cb06390 14 REALSXP g0c3 [OBJ,NAM(2)] (len=3, tl=0) 41,42,43 - notScalar = notScalar || XLENGTH(e) != 1; + notScalar = notScalar || (TYPEOF(e) != S4SXP && XLENGTH(e) != 1); object = object || Rf_isObject(e); attribs = attribs || object || ATTRIB(e) != R_NilValue; notFastVecelt = notFastVecelt || !fastVeceltOk(e);