Skip to content

dartdevc generates incorrect code for a function typed bounds check #31681

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

Closed
eernstg opened this issue Dec 18, 2017 · 2 comments
Closed

dartdevc generates incorrect code for a function typed bounds check #31681

eernstg opened this issue Dec 18, 2017 · 2 comments
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler

Comments

@eernstg
Copy link
Member

eernstg commented Dec 18, 2017

Consider the following program:

class D<X, Y extends List<X Function(X)>> {}
main() => new D();

When compiling this with dartdevc (version 2.0.0-dev.7.0) and running it we get the following failure at run time:

For Dart source maps: npm install source-map-support
ReferenceError: X is not defined ReferenceError: X is not defined
    at XToX (/usr/local/google/home/eernst/lang/dart/scratch/201712/n016.js:8:56)
    at ListOfXToX (/usr/local/google/home/eernst/lang/dart/scratch/201712/n016.js:9:62)
    at DOfdynamic$ListOfXToX (/usr/local/google/home/eernst/lang/dart/scratch/201712/n016.js:10:95)
    at n016.main (/usr/local/google/home/eernst/lang/dart/scratch/201712/n016.js:24:15)
    at Object.dart._checkAndCall (/usr/local/google/home/eernst/devel/dart/work/sdk/pkg/dev_compiler/gen/sdk/common/dart_sdk.js:4642:14)
    at Object.dart.dcall (/usr/local/google/home/eernst/devel/dart/work/sdk/pkg/dev_compiler/gen/sdk/common/dart_sdk.js:4647:15)
    at _isolate_helper._IsolateContext.new.eval (/usr/local/google/home/eernst/devel/dart/work/sdk/pkg/dev_compiler/gen/sdk/common/dart_sdk.js:12721:21)
    at Object._isolate_helper.startRootIsolate (/usr/local/google/home/eernst/devel/dart/work/sdk/pkg/dev_compiler/gen/sdk/common/dart_sdk.js:12516:17)
    at Object.<anonymous> (/usr/local/google/home/eernst/lang/dart/scratch/201712/n016.run.js:12:27)
    at Module._compile (module.js:635:30)
    at Object.Module._extensions..js (module.js:646:10)
    at Module.load (module.js:554:32)
    at tryModuleLoad (module.js:497:12)
    at Function.Module._load (module.js:489:3)
    at Function.Module.runMain (module.js:676:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3

Apparently, the message ReferenceError: X is not defined indicates that XToX is unable to perform it's duties because it refers to X as a free variable:

let XToX = () => (XToX = dart.constFn(dart.fnTypeFuzzy(X, [X])))();
@eernstg eernstg added web-dev-compiler type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Dec 18, 2017
@jmesserly
Copy link

This is a bug in Analyzer, probably in instantiateToBounds. The InstanceCreationExpression for new D() is resolved to the static type D<dynamic, List<(X) → X>> ... which is invalid, as X is a free type parameter. CFE/Kernel correctly compute the type as D<dynamic, List<(dynamic) → dynamic>>.

Possibly related to #30379

@vsmenon vsmenon added the area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. label Jul 20, 2019
@Markzipan
Copy link
Contributor

Closed since analyzer DDC is deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) web-dev-compiler
Projects
None yet
Development

No branches or pull requests

5 participants