dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.2k stars 1.57k forks source link

the generated dart:html and dart:svg libraries have analysis issues #33849

Open devoncarew opened 6 years ago

devoncarew commented 6 years ago

They emit with analysis warnings currently; those warnings will likely change to being reported as errors. When that happens, DDC will fail with compile errors when processing those libraries (and this will cause problems when we go to build the SDK).

A workaround short term is to adjust the //pkg/dev_compiler/tool/build_sdk.dart script to pass in the --unsafe-force-compile flag. That would however allow other errors to creep in over time, so would only be viable as a short term solution.

@terrylucas @jmesserly

[error] The final variable 'length' must be initialized. (dart:_interceptors/js_string.dart, line 15, col 9)
[error] The final variable 'origin' must be initialized. (dart:html, line 467, col 3)
[error] The final variable 'origin' must be initialized. (dart:html, line 978, col 3)
[error] The final variables 'form', 'labels' and '3' more must be initialized. (dart:html, line 1769, col 3)
[error] The final variable 'options' must be initialized. (dart:html, line 8538, col 3)
[error] The final variables '_attributes', '_childElementCount' and '21' more must be initialized. (dart:html, line 12105, col 3)
[error] The final variables 'elements', 'form' and '4' more must be initialized. (dart:html, line 15190, col 3)
[error] The final variable 'length' must be initialized. (dart:html, line 15863, col 3)
[error] The final variables '_get_contentWindow' and 'sandbox' must be initialized. (dart:html, line 17863, col 3)
[error] The final variables 'complete', 'currentSrc' and '2' more must be initialized. (dart:html, line 18060, col 3)
[error] The final variables '_get_valueAsDate', 'entries' and '6' more must be initialized. (dart:html, line 18169, col 3)
[error] The final variables 'control' and 'form' must be initialized. (dart:html, line 19118, col 3)
[error] The final variable 'form' must be initialized. (dart:html, line 19147, col 3)
[error] The final variables 'import', 'relList' and '2' more must be initialized. (dart:html, line 19197, col 3)
[error] The final variable 'areas' must be initialized. (dart:html, line 19328, col 3)
[error] The final variables 'audioDecodedByteCount', 'audioTracks' and '18' more must be initialized. (dart:html, line 19437, col 3)
[error] The final variable 'labels' must be initialized. (dart:html, line 20551, col 3)
[error] The final variables 'baseUri', 'childNodes' and '11' more must be initialized. (dart:html, line 21960, col 3)
[error] The final variables '_get_contentWindow', 'form' and '3' more must be initialized. (dart:html, line 22689, col 3)
[error] The final variables 'form' and 'index' must be initialized. (dart:html, line 23080, col 3)
[error] The final variables 'form', 'htmlFor' and '5' more must be initialized. (dart:html, line 23131, col 3)
[error] The final variables 'labels' and 'position' must be initialized. (dart:html, line 24636, col 3)
[error] The final variables 'form', 'labels' and '4' more must be initialized. (dart:html, line 26268, col 3)
[error] The final variable 'sheet' must be initialized. (dart:html, line 27823, col 3)
[error] The final variable 'cellIndex' must be initialized. (dart:html, line 27993, col 3)
[error] The final variables '_rows' and '_tBodies' must be initialized. (dart:html, line 28092, col 3)
[error] The final variables '_cells', 'rowIndex' and '1' more must be initialized. (dart:html, line 28178, col 3)
[error] The final variable '_rows' must be initialized. (dart:html, line 28234, col 3)
[error] The final variable 'content' must be initialized. (dart:html, line 28288, col 3)
[error] The final variables 'form', 'labels' and '5' more must be initialized. (dart:html, line 28360, col 3)
[error] The final variables 'readyState' and 'track' must be initialized. (dart:html, line 29095, col 3)
[error] The final variables 'decodedFrameCount', 'droppedFrameCount' and '2' more must be initialized. (dart:html, line 29915, col 3)
[error] The final variable 'sourceCapabilities' must be initialized. (dart:html, line 38872, col 3)
[error] The final variables 'href' and 'target' must be initialized. (dart:svg, line 54, col 3)
[error] The final variables 'requiredExtensions', 'systemLanguage' and '1' more must be initialized. (dart:svg, line 394, col 3)
[error] The final variables 'cx', 'cy' and '1' more must be initialized. (dart:svg, line 437, col 3)
[error] The final variable 'clipPathUnits' must be initialized. (dart:svg, line 464, col 3)
[error] The final variables 'cx', 'cy' and '2' more must be initialized. (dart:svg, line 546, col 3)
[error] The final variables 'height', 'in1' and '6' more must be initialized. (dart:svg, line 580, col 3)
[error] The final variables 'height', 'in1' and '6' more must be initialized. (dart:svg, line 641, col 3)
[error] The final variables 'height', 'in1' and '4' more must be initialized. (dart:svg, line 700, col 3)
[error] The final variables 'height', 'in1' and '10' more must be initialized. (dart:svg, line 738, col 3)
[error] The final variables 'bias', 'divisor' and '15' more must be initialized. (dart:svg, line 804, col 3)
[error] The final variables 'diffuseConstant', 'height' and '8' more must be initialized. (dart:svg, line 879, col 3)
[error] The final variables 'height', 'in1' and '8' more must be initialized. (dart:svg, line 932, col 3)
[error] The final variables 'azimuth' and 'elevation' must be initialized. (dart:svg, line 994, col 3)
[error] The final variables 'height', 'result' and '3' more must be initialized. (dart:svg, line 1029, col 3)
[error] The final variables 'height', 'in1' and '6' more must be initialized. (dart:svg, line 1192, col 3)
[error] The final variables 'height', 'href' and '5' more must be initialized. (dart:svg, line 1243, col 3)
[error] The final variables 'height', 'result' and '3' more must be initialized. (dart:svg, line 1292, col 3)
[error] The final variable 'in1' must be initialized. (dart:svg, line 1334, col 3)
[error] The final variables 'height', 'in1' and '7' more must be initialized. (dart:svg, line 1364, col 3)
[error] The final variables 'dx', 'dy' and '6' more must be initialized. (dart:svg, line 1416, col 3)
[error] The final variables 'x', 'y' and '1' more must be initialized. (dart:svg, line 1464, col 3)
[error] The final variables 'height', 'in1' and '9' more must be initialized. (dart:svg, line 1501, col 3)
[error] The final variables 'limitingConeAngle', 'pointsAtX' and '6' more must be initialized. (dart:svg, line 1555, col 3)
[error] The final variables 'height', 'in1' and '4' more must be initialized. (dart:svg, line 1602, col 3)
[error] The final variables 'baseFrequencyX', 'baseFrequencyY' and '9' more must be initialized. (dart:svg, line 1647, col 3)
[error] The final variables 'filterUnits', 'height' and '5' more must be initialized. (dart:svg, line 1713, col 3)
[error] The final variables 'height', 'width' and '2' more must be initialized. (dart:svg, line 1794, col 3)
[error] The final variable 'pathLength' must be initialized. (dart:svg, line 1844, col 3)
[error] The final variables 'farthestViewportElement', 'nearestViewportElement' and '3' more must be initialized. (dart:svg, line 1871, col 3)
[error] The final variables 'height', 'href' and '4' more must be initialized. (dart:svg, line 1912, col 3)
[error] The final variables 'x1', 'x2' and '2' more must be initialized. (dart:svg, line 2074, col 3)
[error] The final variables 'x1', 'x2' and '2' more must be initialized. (dart:svg, line 2103, col 3)
[error] The final variables 'markerHeight', 'markerUnits' and '7' more must be initialized. (dart:svg, line 2132, col 3)
[error] The final variables 'height', 'maskContentUnits' and '6' more must be initialized. (dart:svg, line 2189, col 3)
[error] The final variables 'height', 'href' and '10' more must be initialized. (dart:svg, line 2405, col 3)
[error] The final variables 'animatedPoints' and 'points' must be initialized. (dart:svg, line 2506, col 3)
[error] The final variables 'animatedPoints' and 'points' must be initialized. (dart:svg, line 2531, col 3)
[error] The final variables 'cx', 'cy' and '4' more must be initialized. (dart:svg, line 2600, col 3)
[error] The final variables 'height', 'rx' and '4' more must be initialized. (dart:svg, line 2653, col 3)
[error] The final variable 'href' must be initialized. (dart:svg, line 2686, col 3)
[error] The final variable 'gradientOffset' must be initialized. (dart:svg, line 2742, col 3)
[error] The final variable 'sheet' must be initialized. (dart:svg, line 2842, col 3)
[error] The final variables 'ownerSvgElement' and 'viewportElement' must be initialized. (dart:svg, line 3178, col 3)
[error] The final variables 'currentTranslate', 'height' and '5' more must be initialized. (dart:svg, line 3349, col 3)
[error] The final variables 'preserveAspectRatio' and 'viewBox' must be initialized. (dart:svg, line 3471, col 3)
[error] The final variables 'lengthAdjust' and 'textLength' must be initialized. (dart:svg, line 3531, col 3)
[error] The final variables 'href', 'method' and '2' more must be initialized. (dart:svg, line 3598, col 3)
[error] The final variables 'dx', 'dy' and '3' more must be initialized. (dart:svg, line 3638, col 3)
[error] The final variables 'height', 'href' and '3' more must be initialized. (dart:svg, line 3847, col 3)
[error] The final variables 'preserveAspectRatio' and 'viewBox' must be initialized. (dart:svg, line 3880, col 3)
[error] The final variables 'gradientTransform', 'gradientUnits' and '2' more must be initialized. (dart:svg, line 3927, col 3)

This is related to https://github.com/dart-lang/sdk/issues/33837.

terrylucas commented 6 years ago

Devon (most of these final fields) are RO atttributes in an IDL file. We don't construct these they are browser objects. Should these fields be prefaced with @external or something else to signal that these are special final fields?

devoncarew commented 6 years ago

So, the implementation of the fields are native? Or, the values are injected from outside of Dart?

I'm not sure what we could respect to ignore the analysis issue, but it sounds like we just need to indicate to the analyzer that these are indeed not real issues.

You could try // ignore: final_not_initialized at the declaration sites.

devoncarew commented 6 years ago

But, DDC would likely still fail the compile; hmm...

matanlurey commented 6 years ago

Isn't final String readOnlyThing; the same as external String get readOnlyThing; in this regard?

devoncarew commented 6 years ago

👍 that would be a good solution here

jmesserly commented 6 years ago

Isn't final String readOnlyThing; the same as external String get readOnlyThing; in this regard?

yeah, that would be better from my perspective.

dart:html is shared between DDC and dart2js. Not sure if DDC and/or dart2js have anything hardcoded to treat final fields on @Native specially (compared to external get). If they do, it should be fixable though.

jmesserly commented 6 years ago

Looked into this more. For native types in DDC, external get should be equivalent to a final field. I found an example of DDC using external get in another library (dart:_native_typed_data).

Not sure about dart2js. I couldn't find any examples of them using an external getter in their SDK implementation. Maybe @rakudrama or @sigmundch knows? We could also try changing the dart:html generator to produce external and see if it works :)

devoncarew commented 6 years ago

Note that this may not longer be a blocker for #33837 (but likely still nice to have the generated code be free of analysis warnings and errors).

sigmundch commented 6 years ago

I have to dig deeper to confirm, but @johnniwinther was recently navigating into fields/external getters in the context of js-interop so he might be able to confirm more quickly

johnniwinther commented 6 years ago

Currently, dart2js special-cases fields in native classes. Long term these should be external getters but I suspect that it's not a simple fix to change dart2js.