jinyus / dart_beacon

A reactive primitive (signals) and state management library for dart and flutter
https://pub.dev/packages/state_beacon
28 stars 2 forks source link

Flutter build release fails #109

Closed scalz closed 2 months ago

scalz commented 2 months ago

Description

Hello, I started using state_beacon in my project (thx for your nice work). At the moment I'm using latest flutter beta branch, but maybe same error could happen with stable branch. Everything works fine in debug mode so far, but when I tried to build in release mode I got the error below. I narrowed it down to a controller that I started to use recently which uses state_beacon.

I'm not sure if state_beacon has a bug, if I'm doing something wrong (no analysis error in my project), or if this is a bug in Flutter compiler (still I think if it works in debug mode, release mode should do too).

Thank you for your help.

Unhandled exception:
"Parameter" statement should not be referenced: %value
#0      _SummaryNormalizer.visitParameter (package:vm/transformations/type_flow/summary_collector.dart:178)
#1      Parameter.accept (package:vm/transformations/type_flow/summary.dart:94)
#2      _SummaryNormalizer._normalizeExpr (package:vm/transformations/type_flow/summary_collector.dart:99)
#3      _SummaryNormalizer.visitTypeCheck (package:vm/transformations/type_flow/summary_collector.dart:225)
#4      TypeCheck.accept (package:vm/transformations/type_flow/summary.dart:657)
#5      _SummaryNormalizer._normalizeExpr (package:vm/transformations/type_flow/summary_collector.dart:99)
#6      _SummaryNormalizer.normalize (package:vm/transformations/type_flow/summary_collector.dart:79)
#7      SummaryCollector.createSummary (package:vm/transformations/type_flow/summary_collector.dart:892)
#8      TypeFlowAnalysis.getFieldValue (package:vm/transformations/type_flow/analysis.dart:1801)
#9      _DirectInvocation._processField (package:vm/transformations/type_flow/analysis.dart:294)
#10     _DirectInvocation.process (package:vm/transformations/type_flow/analysis.dart:285)
#11     _WorkList.processInvocation (package:vm/transformations/type_flow/analysis.dart:1663)
#12     _DispatchableInvocation.process.<anonymous closure> (package:vm/transformations/type_flow/analysis.dart:544)
#13     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633)
#14     _DispatchableInvocation.process (package:vm/transformations/type_flow/analysis.dart:518)
#15     _WorkList.processInvocation (package:vm/transformations/type_flow/analysis.dart:1663)
#16     TypeFlowAnalysis.applyCall (package:vm/transformations/type_flow/analysis.dart:1936)
#17     Call.apply (package:vm/transformations/type_flow/summary.dart:358)
#18     Summary.apply (package:vm/transformations/type_flow/summary.dart:1079)
#19     _DirectInvocation._processFunction (package:vm/transformations/type_flow/analysis.dart:407)
#20     _DirectInvocation.process (package:vm/transformations/type_flow/analysis.dart:287)
#21     _WorkList.processInvocation (package:vm/transformations/type_flow/analysis.dart:1663)
#22     _DispatchableInvocation.process.<anonymous closure> (package:vm/transformations/type_flow/analysis.dart:544)
#23     _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:633)

Steps To Reproduce

Using latest available flutter beta branch:

  1. git clone https://github.com/scalz/repro_flutter_build_fail
  2. flutter build apk --release
  3. See error

Expected Behavior

No build release error.

Screenshots

No screenshot.

Additional Context

It works well in debug mode, only release mode fails.

scalz commented 2 months ago

It seems that this error triggers because of using generic type. If I remove generic type and force using String for instance, then release mode builds without error. Do you want me to create an issue on Flutter repo, or am I mis-using BeaconController with generic type ?

jinyus commented 2 months ago

This builds fine with stable branch. Is there any particular reason why you need the beta sdk?

scalz commented 2 months ago

thx for reply. I switched because I needed some fixes which were not available in stable branch yet. I should take a look if they now are. It happened many times that I avoided annoying bugs in stable which were not present in beta, so, sometimes I switch between stable and beta, and this also allows me to check for future deprecated/breaking changes :)

I wonder if this error will trigger in a future stable version though. We can close this issue if you think it's not a bug in state_beacon, and I'll ask on flutter repo why this error trigger (maybe a bug in dart sdk..)

I got lucky to narrow this error to my recents experimentations with state_beacon, because my project is quite large, and the log doesn't tell where this error comes from.

jinyus commented 2 months ago

Yea I think the issue is in dart sdk because state_beacon doesn't show up in the stacktrace.