google / reflectable.dart

Reflectable is a Dart library that allows programmers to eliminate certain usages of dynamic reflection by specialization of reflective code to an equivalent implementation using only static techniques. The use of dynamic reflection is constrained in order to ensure that the specialized code can be generated and will have a reasonable size.
https://pub.dev/packages/reflectable
BSD 3-Clause "New" or "Revised" License
374 stars 56 forks source link

running in web / debug causes a reflection exception before loading #285

Closed VirusEcks closed 1 year ago

VirusEcks commented 1 year ago

trying to run in debug causes the reflectable package to throw exception in debug only in web but it runs fine in profile and release and (debug/release/profile) on other platforms i'm using version 3.0.9 flutter 3.0.5

Screen Shot 2022-08-03 at 5 34 57 PM Screen Shot 2022-08-03 at 5 30 14 PM

https://pastebin.com/A40Vxwih

that is the full html tree at the time of exception with notes to the several lines of "packages"

eernstg commented 1 year ago

@rakudrama, perhaps you could comment on this, or suggest someone else who might recognize the situation: Does 'Uncaught TypeError: Cannot read properties of undefined' look like a code generation issue during compilation to JavaScript? Alternatively, does it ring some other bell?

VirusEcks commented 1 year ago

@eernstg after days of testing -> recompiling prior to submitting this issue until today. our team finally found the problem (facepalm) the problem was never the reflectable package, it was the dart js compiler and partially in fault the dart-lang as well here is a simple explanation for this error in any enum declare a variable named "name" or "index" and the code will be valid in all builds except web/debug because javascript compiler uses the same names used in dart code but in web/release the compression/obfuscation avoids this issue so the generated code will be for example

order_popup_widget.OrderValue = class OrderValue extends core._Enum {
    toString() {
      return "OrderValue." + this[S._name];
    }
    static ['_#new#tearOff'](index, name, name) {
      return new order_popup_widget.OrderValue.new(index, name, name);
    }
  };

where the second name will be undefined after refactoring this variable named name the debug ran smoothly

eernstg commented 1 year ago

in any enum declare a variable named "name" or "index"

Ah, yes, that's a known bug, I think the fix is on the way.