Returns false when the binding could NOT be recorded in THIS frame. * * The failure that matters is arena exhaustion in alloc_chunk: the old void * form returned silently, so a caller that then consulted the scope CHAIN saw * the parent's binding for the same name and concluded the child had been * bound. For callable-value proof that is a fabricated identity -- the shadow * never took effec
| 167 | * needing that distinction must use the checked form and consult the LOCAL |
| 168 | * result, not a chain lookup. */ |
| 169 | static bool cbm_scope_bind_value(CBMScope *scope, const char *name, const CBMType *type, |
| 170 | const char *callable_qn) { |
| 171 | if (!scope || !name) { |
| 172 | return false; |
| 173 | } |
| 174 | CBMVarBinding *existing = scope_frame_find(scope, name); |
| 175 | if (existing) { |
| 176 | existing->type = type; |
| 177 | existing->callable_qn = callable_qn; |
| 178 | return true; |
| 179 | } |
| 180 | CBMScopeChunk* head = scope->chunks; |
| 181 | if (!head || head->used >= CBM_SCOPE_CHUNK_BINDINGS) { |
| 182 | head = alloc_chunk(scope); |
| 183 | if (!head) { |
| 184 | return false; /* arena exhausted: the shadow did NOT take effect */ |
| 185 | } |
| 186 | } |
| 187 | CBMVarBinding *b = &head->bindings[head->used]; |
| 188 | b->name = name; |
| 189 | b->type = type; |
| 190 | b->callable_qn = callable_qn; |
| 191 | head->used++; |
| 192 | scope->binding_count++; |
| 193 | scope_index_note(scope, b); |
| 194 | return true; |
| 195 | } |
| 196 | |
| 197 | void cbm_scope_bind(CBMScope *scope, const char *name, const CBMType *type) { |
| 198 | (void)cbm_scope_bind_value(scope, name, type, NULL); |
no test coverage detected