Repository navigation
Closed
Labels
BugIssues indicating incorrect or broken behavior.Issues indicating incorrect or broken behavior.DiagnosticsImproving or fixing compiler error messages.Improving or fixing compiler error messages.Error HandlingRelated to error reporting, diagnostics, and warnings.Related to error reporting, diagnostics, and warnings.Good First IssueSimple tasks suitable for newcomers.Simple tasks suitable for newcomers.Semantic AnalysisPertaining to type checking, scopes, or analysis.Pertaining to type checking, scopes, or analysis.
Description
Compiler version
kairo-0.1.1+dev.20261024
Compiler stage
Stage 1 (self-hosted)
Host platform
Linux (x86_64)
Minimal reproduction
// Tests/Bugs/Triage/F15-poisoned-cast-argument-cascades-into-sc063e.k
ffi "c" import "stdlib.h"
fn main() -> i32 {
var p: unsafe *const u8
unsafe { p = malloc(4) as unsafe *const u8 }
free(p as unsafe *void) // SC023E is right; the SC063E beside it is a cascade
return 0
}Command line
build/x86_64-linux-gnu/debug/bin/kairo --resource-dir=build/llvm/lib/clang/22 --builtins-dir=Lib/builtin --std-dir=Lib/std Tests/Bugs/Triage/F15-poisoned-cast-argument-cascades-into-sc063e.k --type-check-onlyActual behavior
error @ Tests/Bugs/Triage/F15-poisoned-cast-argument-cascades-into-sc063e.k:7
5 | var p: unsafe *const u8
6 | unsafe { p = malloc(4) as unsafe *const u8 }
7 | free(p as unsafe *void) // SC023E is right; the SC063E beside it is a cascade
| ^^^^^^^^^^^^^^^^^^^^^^^
| | [SC023E] cast to 'unsafe *void' requires an unsafe context
| [SC063E] no matching overload for call to 'free'
note @ build/x86_64-linux-gnu/release/sysroot/x86_64-linux-musl/include/stdlib.h:43
41 | void *calloc (size_t, size_t);
42 | void *realloc (void *, size_t);
43 | void free (void *);
| ^ candidate not viable: cannot convert argument of type '<literal>' to parameter '__arg0' of type 'unsafe *void'
note @ Tests/Bugs/Triage/F15-poisoned-cast-argument-cascades-into-sc063e.k:7
5 | var p: unsafe *const u8
6 | unsafe { p = malloc(4) as unsafe *const u8 }
7 | free(p as unsafe *void) // SC023E is right; the SC063E beside it is a cascade
| ^ wrap the expression in 'unsafe { ... }'; this cast discards pointer provenance
Exit code 1.Expected behavior
Only SC023E (with its unsafe { ... } note) is reported. The poisoned argument makes the call poisoned without a diagnostic.
Additional context
The SC063E is reported first; with --error-format=basic the order is:
Tests/Bugs/Triage/F15-poisoned-cast-argument-cascades-into-sc063e.k:7:5: error [SC063E]: no matching overload for call to 'free'
build/x86_64-linux-gnu/release/sysroot/x86_64-linux-musl/include/stdlib.h:43:1: note [I900N]: candidate not viable: cannot convert argument of type '<literal>' to parameter '__arg0' of type 'unsafe *void'
Tests/Bugs/Triage/F15-poisoned-cast-argument-cascades-into-sc063e.k:7:10: error [SC023E]: cast to 'unsafe *void' requires an unsafe context
Tests/Bugs/Triage/F15-poisoned-cast-argument-cascades-into-sc063e.k:7:10: note [I900N]: wrap the expression in 'unsafe { ... }'; this cast discards pointer provenance
The argument is poisoned, so overload resolution should treat it as unknown and stay silent, as check_convertible does for a poisoned expression. '' is also the wrong name for its type.
Fix: OverloadResolution skips viability reporting when an argument is poisoned (poison the call, no diagnostic). Test: the repro reports SC023E only.
Metadata
Metadata
Assignees
Labels
BugIssues indicating incorrect or broken behavior.Issues indicating incorrect or broken behavior.DiagnosticsImproving or fixing compiler error messages.Improving or fixing compiler error messages.Error HandlingRelated to error reporting, diagnostics, and warnings.Related to error reporting, diagnostics, and warnings.Good First IssueSimple tasks suitable for newcomers.Simple tasks suitable for newcomers.Semantic AnalysisPertaining to type checking, scopes, or analysis.Pertaining to type checking, scopes, or analysis.
Activity
Ze7111 commentedon Nov 9, 2026
a poisoned cast argument cascading into SC063E naming '' (only SC023E is reported now; the exact fixing commit was not pinpointed, it landed somewhere in the 2026-10-24..11-04 Sema work), fixed on origin/main