Skip to content

Commit 7effa3c

Browse files
committed
test(python): check the type of the package-scope Store binding
cbm_scope_lookup_local() returns the frame binding (CBMVarBinding), not its type, so passing it to pylsp_init_named_type() did not compile (-Werror=incompatible-pointer-types). Add pylsp_local_type(), which returns the binding's type field or NULL when the name is unbound, and assert on that type as the test intended. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 57e04c6 commit 7effa3c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎tests/test_py_lsp.c‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3132,6 +3132,12 @@ static bool pylsp_init_named_type(const CBMType *type, const char *qn) {
31323132
strcmp(type->data.named.qualified_name, qn) == 0;
31333133
}
31343134

3135+
/* Type of the binding of name in this frame only, or NULL when unbound. */
3136+
static const CBMType *pylsp_local_type(const CBMScope *scope, const char *name) {
3137+
const CBMVarBinding *binding = cbm_scope_lookup_local(scope, name);
3138+
return binding ? binding->type : NULL;
3139+
}
3140+
31353141
static bool pylsp_init_signature(const CBMTypeRegistry *registry, const char *function,
31363142
const char *expected_type) {
31373143
const CBMRegisteredFunc *f = cbm_registry_lookup_func(registry, function);
@@ -3257,7 +3263,7 @@ TEST(pylsp_init_scope_external_classes_and_cross_exact_joins) {
32573263
py_lsp_init(&ctx, &arena, source, (int)strlen(source), &overlay, "test.pkg.__init__", &out);
32583264
cbm_py_lsp_test_bind_external_classes(&ctx, ts_tree_root_node(tree));
32593265
bool globals = base && ctx.eval_failure == CBM_LSP_COMPLETE &&
3260-
pylsp_init_named_type(cbm_scope_lookup_local(ctx.current_scope, "Store"),
3266+
pylsp_init_named_type(pylsp_local_type(ctx.current_scope, "Store"),
32613267
"test.pkg.Store") &&
32623268
!cbm_scope_lookup_local(ctx.current_scope, "Widget") &&
32633269
!cbm_scope_lookup_local(ctx.current_scope, "Nested");

0 commit comments

Comments
 (0)