-
-
Notifications
You must be signed in to change notification settings - Fork 667
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug] Returning an unmanaged class results in a retain #761
Comments
Looks like it's coming from the variableStatement. initExpr = this.compileExpression(declaration.initializer, Type.auto,
Constraints.WILL_RETAIN
); // reports
initAutoreleaseSkipped = this.skippedAutoreleases.has(initExpr); How do you determine if an |
The compiler should only insert RT calls if |
I'm trying to trace it. It's very hard. |
I hate to be a bother, but I did find another compiler bug for sure. @unmanaged
class ExampleClass {}
static report<T>(actual: T): void {
// get the stack trace
Actual.stackTrace = getStackTrace();
// if T is a reference type...
if (isReference<T>()) {
if (isNullable<T>()) {
if (actual === null) {
Actual.type = ValueType.Null;
return;
}
}
let ptr = changetype<usize>(actual);
// if the reference is managed, retain it for later reporting
if (isManaged<T>()) __retain(ptr); I accounted for this with the fixed and rebuilt compiler to make sure that my testing software wasn't retaining the reference directly. (func $../cli/node_modules/@as-pect/assembly/assembly/internal/report/Actual/Actual.report<assembly/__tests__/unmanaged.spec/ExampleClass> (; 59 ;) (type $FUNCSIG$vi) (param $0 i32)
(local $1 i32)
call $../cli/node_modules/@as-pect/assembly/assembly/internal/report/Actual/getStackTrace
global.set $../cli/node_modules/@as-pect/assembly/assembly/internal/report/Actual/Actual.stackTrace
local.get $0
local.set $1
local.get $1
call $~lib/rt/pure/__retain
drop This is unoptimized output, but the last 5 instructions get the parameter and then retain it immediately after setting the I'll work on reproducing a smaller concise example. |
The first |
The assertion is from not providing |
Actually you're right. I'm forgetting the generic parameter in the example. For some reason, however, the initial example I provided seems to call |
Yeah. The problem was on me double-fold. I had to build the compiler from source to test and validate that it worked correctly. Hopefully, dist files can be updated soon. |
It's not accounting for the
@unmanaged Example
class.The text was updated successfully, but these errors were encountered: