-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Error with private variable setters in mixins on dart web. #50119
Comments
Same error doesn't exist with |
Here is a minimal reproducible snippet without riverpod (using the web-simple template): // main.dart
import 'baz.dart';
void main() {
var foo = Foo();
print(foo.bar());
}
class Foo = Bar with Baz;
class Bar {} // baz.dart
mixin Baz {
int? _foo;
void bar() {
_foo = 100;
}
} The error happens only, when the |
Any update on this ?! |
I'm "engaging" with the engineers now. Thanks for your patience! |
Upvoting this because this is a blocking issue with a client. |
I narrowed down a little more from @schultek's example.
|
@leehack – did that patch to riverpod fix the issue? |
@kevmoo yep. It's tested and merged in the main, but I wish it to be fixed from dart anyway. I think the syntax makes the code cleaner. Not sure how widespread the syntax is, but maybe there are many packages impacted by this issue. |
Also, it'd be nice for that syntax to also be documented somewhere. The first I saw it was in the RiverPod code, and Remi claims that he found it by going through the compiler sources. :) |
Thank you @TimWhiting and other for reporting the issue and providing a great repro! I am looking into this currently, apologies for the delay. Maybe related: #46867 Looks like this is the culprit DDC-generated code that causes the stack overflow. Will see how it can be fixed: class AutoDisposeFutureProviderElement extends FutureProviderElement_AutoDisposeProviderElementMixin$36 {
static ['_#_#tearOff'](T, provider) {
return new (future_provider.AutoDisposeFutureProviderElement$(T)).__(provider);
}
get [_keepAliveLinks]() {
return this[_keepAliveLinks]; // Calling itself here!
}
set [_keepAliveLinks](value) {
return this[_keepAliveLinks] = value;
}
get [_maintainState]() {
return this[_maintainState];
}
set [_maintainState](value) {
return this[_maintainState] = value;
}
get maintainState() {
return super.maintainState;
}
set maintainState(value) {
return super.maintainState = value;
}
keepAlive() {
return super.keepAlive();
}
mayNeedDispose() {
return super.mayNeedDispose();
}
runOnDispose() {
return super.runOnDispose();
}
} |
@leehack thank you for the great repro! Here is where the fault lies. I'll post updates on my progress. /// Generated by DDC, the Dart Development Compiler (to JavaScript).
// Version: 2.19.0-319.0.dev (dev) (Tue Oct 18 17:25:31 2022 -0700) on "macos_x64"
// Module: packages/hello_world/main.dart
// Flags: soundNullSafety(true), enableAsserts(true)
define(['dart_sdk', 'packages/hello_world/baz.dart'], (function load__packages__hello_world__main_dart(dart_sdk, packages__hello_world__baz$46dart) {
'use strict';
const core = dart_sdk.core;
const dart = dart_sdk.dart;
const dartx = dart_sdk.dartx;
const baz = packages__hello_world__baz$46dart.baz;
var main = Object.create(dart.library);
dart._checkModuleNullSafetyMode(true);
dart._checkModuleRuntimeTypes(false);
const CT = Object.create({
_: () => (C, CT)
});
var I = ["package:hello_world/main.dart"];
var _foo = dart.privateName(baz, "_foo");
main.Bar = class Bar extends core.Object {
static ['_#new#tearOff']() {
return new main.Bar.new();
}
};
(main.Bar.new = function() {
;
}).prototype = main.Bar.prototype;
dart.addTypeTests(main.Bar);
dart.addTypeCaches(main.Bar);
dart.setLibraryUri(main.Bar, I[0]);
const Bar_Baz$36 = class Bar_Baz extends main.Bar {};
(Bar_Baz$36.new = function() {
baz.Baz[dart.mixinNew].call(this);
}).prototype = Bar_Baz$36.prototype;
dart.applyMixin(Bar_Baz$36, baz.Baz);
main.Foo = class Foo extends Bar_Baz$36 {
static ['_#new#tearOff']() {
return new main.Foo.new();
}
get [_foo]() {
return this[_foo];
}
set [_foo](value) {
return this[_foo] = value; // CALLS ITSELF!
}
bar() {
return super.bar();
}
};
(main.Foo.new = function() {
main.Foo.__proto__.new.call(this);
;
}).prototype = main.Foo.prototype;
dart.addTypeTests(main.Foo);
dart.addTypeCaches(main.Foo);
dart.setMethodSignature(main.Foo, () => ({
__proto__: dart.getMethods(main.Foo.__proto__),
bar: dart.fnType(dart.void, [])
}));
dart.setGetterSignature(main.Foo, () => ({
__proto__: dart.getGetters(main.Foo.__proto__),
[_foo]: dart.nullable(core.int)
}));
dart.setSetterSignature(main.Foo, () => ({
__proto__: dart.getSetters(main.Foo.__proto__),
[_foo]: dart.nullable(core.int)
}));
dart.setLibraryUri(main.Foo, I[0]);
const Bar_Baz$36$ = class Bar_Baz extends main.Bar {};
(Bar_Baz$36$.new = function() {
baz.Baz[dart.mixinNew].call(this);
}).prototype = Bar_Baz$36$.prototype;
dart.applyMixin(Bar_Baz$36$, baz.Baz);
main.FooWork = class FooWork extends Bar_Baz$36$ {
static ['_#new#tearOff']() {
return new main.FooWork.new();
}
};
(main.FooWork.new = function() {
main.FooWork.__proto__.new.call(this);
;
}).prototype = main.FooWork.prototype;
dart.addTypeTests(main.FooWork);
dart.addTypeCaches(main.FooWork);
dart.setLibraryUri(main.FooWork, I[0]);
main.main = function main$() {
let foo = new main.Foo.new();
let fooWork = new main.FooWork.new();
fooWork.bar();
foo.bar();
};
dart.trackLibraries("packages/hello_world/main.dart", {
"package:hello_world/main.dart": main
}, {
}, '{"version":3,"sourceRoot":"","sources":["main.dart"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAkBW;;;;;;;;;;;;;;AAHL;;;+BAAK;;;AAAL;;;;;;EAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EACW;;;;;AAP7B,cAAM;AACN,kBAAU;AACD,IAAb,AAAQ,OAAD;AACE,IAAT,AAAI,GAAD;EACL","file":"../../../../../../../../packages/hello_world/main.dart.lib.js"}');
// Exports:
return {
main: main
};
}));
//# sourceMappingURL=main.dart.lib.js.map |
Update: found the culprit - we haven't marked the mixin declaration class fields as virtual, so overrides were not working correctly. Testing out the fix currently. |
Will this get included in a hotfix release of Dart and Flutter? It's quite a serious issue. I myself ran into it in my large Flutter app that does not use Provider. |
@hacker1024 I am working on it, will update on if and when! |
Generate calls to super class methods from mixin application stubs using `super` instead of `this`. Bug: #50119 Change-Id: I02802ea828d72d9221f1886195acb91e6c9520ac Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/267822 Fixed:#50415 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268604 Reviewed-by: Sigmund Cherem <[email protected]> Reviewed-by: Joshua Litt <[email protected]>
Generate calls to super class methods from mixin application stubs using `super` instead of `this`. Bug: #50119 Change-Id: I87a851579d94d8c497985ee02babb413f56fad21 Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/267822 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268609 Commit-Queue: Alexander Thomas <[email protected]> Reviewed-by: Sigmund Cherem <[email protected]>
dart --version
2.19.0-266.0.dev
, also on stable / beta channelsweb / chrome
Very similar issue to #44636.
Simplest reproduction so far:
Edit: See @schultek's minimum sample below for a simpler reproduction.
dart create -t web-simple call_stack_overflow && cd call_stack_overflow
riverpod: ^2.0.0
webdev serve
Stack overflow on private setter in a mixin. Making the field in the package public shifts the error to another private member.
Originally reported here: rrousselGit/riverpod#1713
I tried creating a more minimal sample, but was unsuccessful.
The text was updated successfully, but these errors were encountered: