@@ -127,35 +127,34 @@ extractTypeParamsPrism(core::MutableContext ctx, const parser::Prism::Parser &pa
127127 * Handles both PM_CONSTANT_READ_NODE (e.g., `G2`) and PM_CONSTANT_PATH_NODE (e.g., `T::Array`).
128128 */
129129bool sameConstant (parser::Prism::Parser &parser, pm_node_t *a, pm_node_t *b) {
130- if (a == nullptr || b = = nullptr ) {
131- return false ;
132- }
130+ while (a != nullptr && b ! = nullptr ) {
131+ pm_node_type aType = PM_NODE_TYPE (a) ;
132+ pm_node_type bType = PM_NODE_TYPE (b);
133133
134- pm_node_type aType = PM_NODE_TYPE (a);
135- pm_node_type bType = PM_NODE_TYPE (b);
134+ if (aType == PM_CONSTANT_READ_NODE && bType == PM_CONSTANT_READ_NODE) {
135+ auto *aConst = down_cast<pm_constant_read_node_t >(a);
136+ auto *bConst = down_cast<pm_constant_read_node_t >(b);
137+ return aConst->name == bConst->name ;
138+ }
136139
137- // Case 1: Both are PM_CONSTANT_READ_NODE (simple constants like `G2`)
138- if (aType == PM_CONSTANT_READ_NODE && bType == PM_CONSTANT_READ_NODE) {
139- auto *aConst = down_cast<pm_constant_read_node_t >(a);
140- auto *bConst = down_cast<pm_constant_read_node_t >(b);
141- return aConst->name == bConst->name ;
142- }
140+ if (aType == PM_CONSTANT_PATH_NODE && bType == PM_CONSTANT_PATH_NODE) {
141+ auto *aPath = down_cast<pm_constant_path_node_t >(a);
142+ auto *bPath = down_cast<pm_constant_path_node_t >(b);
143143
144- // Case 2: Both are PM_CONSTANT_PATH_NODE (scoped constants like `T::Array`)
145- if (aType == PM_CONSTANT_PATH_NODE && bType == PM_CONSTANT_PATH_NODE) {
146- auto *aPath = down_cast<pm_constant_path_node_t >(a);
147- auto *bPath = down_cast<pm_constant_path_node_t >(b);
144+ if (aPath->name != bPath->name ) {
145+ return false ;
146+ }
148147
149- if (aPath->name != bPath->name ) {
150- return false ;
151- }
148+ if (aPath->parent == nullptr && bPath->parent == nullptr ) {
149+ return true ;
150+ }
152151
153- // If both parents are null, we've matched the entire path
154- if (aPath-> parent == nullptr && bPath->parent == nullptr ) {
155- return true ;
152+ a = aPath-> parent ;
153+ b = bPath->parent ;
154+ continue ;
156155 }
157156
158- return sameConstant (parser, aPath-> parent , bPath-> parent ) ;
157+ return false ;
159158 }
160159
161160 return false ;
@@ -317,7 +316,7 @@ bool AssertionsRewriterPrism::saveMethodTypeParams(pm_node_t *call) {
317316
318317 // Check if this is a sig() call
319318 auto methodName = parser.resolveConstant (callNode->name );
320- if (methodName != " sig" ) {
319+ if (methodName != " sig" sv ) {
321320 return false ;
322321 }
323322
0 commit comments