Skip to content
This repository was archived by the owner on Mar 16, 2020. It is now read-only.

ddc investigation #129

Closed
devoncarew opened this issue Jul 29, 2015 · 13 comments
Closed

ddc investigation #129

devoncarew opened this issue Jul 29, 2015 · 13 comments

Comments

@devoncarew
Copy link
Contributor

From the 0.1.4 version of ddc (grind ddc):

severe: [InvalidMethodOverride] Invalid override. The type of BufferWhen.bind ((Stream<T>) → Stream<T>) is not a subtype of StreamTransformer<dynamic, dynamic>.bind ((Stream<dynamic>) → Stream<dynamic>). (package:stream_transformers/src/buffer_when.dart, line 29, col 3)
severe: [StaticTypeError] Type check failed: new Scan({}, (previous, current) {var values = new Map.from(previous); values[current.first] = current.last; return values;}) (Scan<dynamic, dynamic>) is not of type StreamTransformer<List<dynamic>, dynamic> (package:stream_transformers/src/combine.dart, line 30, col 61)
severe: [InvalidMethodOverride] Invalid override. The type of ConcatAll.bind ((Stream<T>) → Stream<R>) is not a subtype of StreamTransformer<dynamic, dynamic>.bind ((Stream<dynamic>) → Stream<dynamic>). (package:stream_transformers/src/concat_all.dart, line 35, col 3)
severe: [InvalidMethodOverride] Invalid override. The type of DoAction.bind ((Stream<T>) → Stream<T>) is not a subtype of StreamTransformer<dynamic, dynamic>.bind ((Stream<dynamic>) → Stream<dynamic>). (package:stream_transformers/src/do_action.dart, line 43, col 3)
severe: [InvalidMethodOverride] Invalid override. The type of FlatMap.bind ((Stream<S>) → Stream<T>) is not a subtype of StreamTransformer<dynamic, dynamic>.bind ((Stream<dynamic>) → Stream<dynamic>). (package:stream_transformers/src/flat_map.dart, line 22, col 3)
severe: [StaticTypeError] Type check failed: new FlatMap((value) => _convert(value).transform(new TakeUntil(done.stream))) (FlatMap<dynamic, dynamic>) is not of type StreamTransformer<S, dynamic> (package:stream_transformers/src/flat_map_latest.dart, line 30, col 22)
severe: [InvalidMethodOverride] Invalid override. The type of Merge.bind ((Stream<S>) → Stream<dynamic>) is not a subtype of StreamTransformer<dynamic, dynamic>.bind ((Stream<dynamic>) → Stream<dynamic>). (package:stream_transformers/src/merge.dart, line 31, col 3)
severe: [InvalidMethodOverride] Invalid override. The type of MergeAll.bind ((Stream<T>) → Stream<dynamic>) is not a subtype of StreamTransformer<dynamic, dynamic>.bind ((Stream<dynamic>) → Stream<dynamic>). (package:stream_transformers/src/merge_all.dart, line 27, col 3)
severe: [StaticTypeError] Type check failed: new FlatMap((stream) => stream) (FlatMap<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:stream_transformers/src/merge_all.dart, line 28, col 29)
severe: [StaticTypeError] Type check failed: new FlatMapLatest((value) {return _bindStream(onListen: (EventSink<T> sink) {return trigger.listen((_) => sink.add(value), onError: sink.addError, onDone: sink.close);});}) (FlatMapLatest<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:stream_transformers/src/sample_on.dart, line 41, col 22)
severe: [InvalidMethodOverride] Invalid override. The type of Scan.bind ((Stream<A>) → Stream<R>) is not a subtype of StreamTransformer<dynamic, dynamic>.bind ((Stream<dynamic>) → Stream<dynamic>). (package:stream_transformers/src/scan.dart, line 29, col 3)
severe: [StaticTypeError] Type check failed: new When(_signal.map((_) => true)) (When<dynamic>) is not of type StreamTransformer<T, dynamic> because _signal.map((_) => true) cannot be typed as Stream<bool> (package:stream_transformers/src/skip_until.dart, line 29, col 29)
severe: [StaticTypeError] Type check failed: new Merge(stream) (Merge<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:stream_transformers/src/start_with.dart, line 30, col 47)
severe: [StaticTypeError] Type check failed: new FlatMapLatest((isToggled) {if (isToggled) {return _bindStream(onListen: (EventSink<T> sink) {return input.listen(sink.add, onError: sink.addError, onDone: sink.close);});} else {return new Stream.fromIterable([]);}}) (FlatMapLatest<dynamic, dynamic>) is not of type StreamTransformer<bool, dynamic> (package:stream_transformers/src/when.dart, line 33, col 22)
severe: [StaticTypeError] Type check failed: new Scan(new Queue<A>(), appendToQueue) (Scan<dynamic, dynamic>) is not of type StreamTransformer<A, dynamic> (package:stream_transformers/src/zip.dart, line 39, col 35)
severe: [StaticTypeError] Type check failed: new Scan(new Queue<B>(), appendToQueue) (Scan<dynamic, dynamic>) is not of type StreamTransformer<B, dynamic> (package:stream_transformers/src/zip.dart, line 40, col 35)
severe: [InvalidMethodOverride] Invalid override. The type of Reactable.handleError ((dynamic, {test: (dynamic) → bool}) → Reactable<T>) is not a subtype of Stream<T>.handleError ((Function, {test: (dynamic) → bool}) → Stream<T>). (package:frappe/src/reactable.dart, line 291, col 3)
severe: [StaticTypeError] Type check failed: new BufferWhen(toggle) (BufferWhen<dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/event_stream.dart, line 94, col 63)
severe: [StaticTypeError] Type check failed: new Concat(other) (Concat<dynamic>) is not of type StreamTransformer<T, dynamic> because other cannot be typed as Stream<T> (package:frappe/src/event_stream.dart, line 98, col 49)
severe: [StaticTypeError] Type check failed: new ConcatAll() (ConcatAll<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/event_stream.dart, line 100, col 40)
severe: [StaticTypeError] Type check failed: new DoAction(onData, onError: onError, onDone: onDone) (DoAction<dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/event_stream.dart, line 109, col 17)
severe: [StaticTypeError] Type check failed: new FlatMap(convert) (FlatMap<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/event_stream.dart, line 113, col 61)
severe: [StaticTypeError] Type check failed: new Merge(other) (Merge<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/event_stream.dart, line 126, col 48)
severe: [StaticTypeError] Type check failed: new MergeAll() (MergeAll<dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/event_stream.dart, line 128, col 39)
severe: [StaticTypeError] Type check failed: new Scan(initialValue, combine) (Scan<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/event_stream.dart, line 136, col 74)
severe: [StaticTypeError] Type check failed: new SelectFirst(other) (SelectFirst) is not of type StreamTransformer<T, dynamic> (package:frappe/src/event_stream.dart, line 138, col 54)
severe: [StaticTypeError] Type check failed: new StartWith.many(values) (StartWith<dynamic>) is not of type StreamTransformer<T, dynamic> because values cannot be typed as Iterable<T> (package:frappe/src/event_stream.dart, line 148, col 61)
severe: [StaticTypeError] Type check failed: new Zip(other, combiner) (Zip<dynamic, dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> because combiner cannot be typed as (T, dynamic) → dynamic (package:frappe/src/event_stream.dart, line 166, col 65)
severe: [StaticTypeError] Type check failed: new EventStream(_controller.stream) (EventStream<dynamic>) is not of type EventStream<T> because _controller.stream cannot be typed as Stream<T> (package:frappe/src/property.dart, line 21, col 33)
severe: [StaticTypeError] Type check failed: new BufferWhen(toggle) (BufferWhen<dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/property.dart, line 105, col 60)
severe: [StaticTypeError] Type check failed: new Concat(other) (Concat<dynamic>) is not of type StreamTransformer<T, dynamic> because other cannot be typed as Stream<T> (package:frappe/src/property.dart, line 109, col 46)
severe: [StaticTypeError] Type check failed: new ConcatAll() (ConcatAll<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/property.dart, line 111, col 37)
severe: [StaticTypeError] Type check failed: new DoAction(onData, onError: onError, onDone: onDone) (DoAction<dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/property.dart, line 120, col 17)
severe: [StaticTypeError] Type check failed: new FlatMap(convert) (FlatMap<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/property.dart, line 124, col 58)
severe: [StaticTypeError] Type check failed: new Merge(other) (Merge<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/property.dart, line 145, col 45)
severe: [StaticTypeError] Type check failed: new MergeAll() (MergeAll<dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/property.dart, line 147, col 36)
severe: [StaticTypeError] Type check failed: new Scan(initialValue, combine) (Scan<dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> (package:frappe/src/property.dart, line 155, col 71)
severe: [StaticTypeError] Type check failed: new SelectFirst(other) (SelectFirst) is not of type StreamTransformer<T, dynamic> (package:frappe/src/property.dart, line 157, col 51)
severe: [StaticTypeError] Type check failed: new StartWith.many(values) (StartWith<dynamic>) is not of type StreamTransformer<T, dynamic> because values cannot be typed as Iterable<T> (package:frappe/src/property.dart, line 167, col 58)
severe: [StaticTypeError] Type check failed: new Zip(other, combiner) (Zip<dynamic, dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> because combiner cannot be typed as (T, dynamic) → dynamic (package:frappe/src/property.dart, line 185, col 62)
severe: [AnalyzerMessage] The getter 'children' is not defined for the class 'Node' (package:markdown/src/inline_parser.dart, line 361, col 10)
severe: [AnalyzerMessage] The getter 'attributes' is not defined for the class 'Node' (package:markdown/src/inline_parser.dart, line 354, col 36)
severe: [AnalyzerMessage] The getter 'text' is not defined for the class 'Node' (package:markdown/src/inline_parser.dart, line 136, col 48)
severe: [AnalyzerMessage] The getter 'children' is not defined for the class 'Node' (package:markdown/src/inline_parser.dart, line 355, col 34)
severe: [AnalyzerMessage] The getter 'attributes' is not defined for the class 'Node' (package:markdown/src/inline_parser.dart, line 353, col 34)
severe: [InvalidSuperInvocation] super call must be last in an initializer list (see http://goo.gl/q1T4BB): super(pattern) (package:markdown/src/inline_parser.dart, line 191, col 9)
severe: [InvalidSuperInvocation] super call must be last in an initializer list (see http://goo.gl/q1T4BB): super(pattern) (package:markdown/src/inline_parser.dart, line 230, col 9)
severe: [AnalyzerMessage] The getter '_end' is not defined for the class 'SourceSpan' (package:source_span/src/file.dart, line 237, col 19)
severe: [AnalyzerMessage] The getter '_start' is not defined for the class 'SourceSpan' (package:source_span/src/file.dart, line 237, col 34)

Looks like the ddc doesn't like frappe, and has a few issues with markdown and source_span.

@radicaled
Copy link
Contributor

Are these bugs in DDC or issues with packages that have gone undetected because Dart allows this ambiguity?

@devoncarew
Copy link
Contributor Author

These are:

  • bugs in the packages that the stricter mode of ddc uncovers (which, +1 for static analysis)
  • a stricter sub-set of dart, which will allow for better (clean, readable) JavaScript output

For the 2nd item, you need to opt-in to what I think amounts to a sound type system in order to get much better JavaScript output. Definitely a trade-off I'd be comfortable with.

@radicaled
Copy link
Contributor

https://github.com/radicaled/dart-markdown/tree/fix_type_problems
https://github.com/radicaled/stream_transformers/tree/fix_type_problems
https://github.com/radicaled/frappe/tree/fix_type_problems

Each branch passes ddc 0.1.1 individually, and changing dartlang's pubspec.yaml to use them as git packages results in a lot of JavaScript files and no errors on compilation. I ran the tests for stream_transformer and frappe in checked mode, everything still seems to work.

The latest ddc package is 0.1.4 though and I'm not on the bleeding edge version of Dart right now -- can you try with that and let me know how it looks?

@devoncarew
Copy link
Contributor Author

Much, much reduced number of errors:

severe: [InvalidMethodOverride] Invalid override. The type of Reactable.handleError ((dynamic, {test: (dynamic) → bool}) → Reactable<T>) is not a subtype of Stream<T>.handleError ((Function, {test: (dynamic) → bool}) → Stream<T>). (package:frappe/src/reactable.dart, line 291, col 3)
severe: [StaticTypeError] Type check failed: new Concat(other) (Concat<dynamic>) is not of type StreamTransformer<T, dynamic> because other cannot be typed as Stream<T> (package:frappe/src/event_stream.dart, line 98, col 49)
severe: [StaticTypeError] Type check failed: new StartWith.many(values) (StartWith<dynamic>) is not of type StreamTransformer<T, dynamic> because values cannot be typed as Iterable<T> (package:frappe/src/event_stream.dart, line 148, col 61)
severe: [StaticTypeError] Type check failed: new Zip(other, combiner) (Zip<dynamic, dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> because combiner cannot be typed as (T, dynamic) → dynamic (package:frappe/src/event_stream.dart, line 166, col 65)
severe: [StaticTypeError] Type check failed: new EventStream(_controller.stream) (EventStream<dynamic>) is not of type EventStream<T> because _controller.stream cannot be typed as Stream<T> (package:frappe/src/property.dart, line 21, col 33)
severe: [StaticTypeError] Type check failed: new Concat(other) (Concat<dynamic>) is not of type StreamTransformer<T, dynamic> because other cannot be typed as Stream<T> (package:frappe/src/property.dart, line 109, col 46)
severe: [StaticTypeError] Type check failed: new StartWith.many(values) (StartWith<dynamic>) is not of type StreamTransformer<T, dynamic> because values cannot be typed as Iterable<T> (package:frappe/src/property.dart, line 167, col 58)
severe: [StaticTypeError] Type check failed: new Zip(other, combiner) (Zip<dynamic, dynamic, dynamic>) is not of type StreamTransformer<T, dynamic> because combiner cannot be typed as (T, dynamic) → dynamic (package:frappe/src/property.dart, line 185, col 62)
severe: [AnalyzerMessage] The getter '_end' is not defined for the class 'SourceSpan' (package:source_span/src/file.dart, line 237, col 19)
severe: [AnalyzerMessage] The getter '_start' is not defined for the class 'SourceSpan' (package:source_span/src/file.dart, line 237, col 34)

@devoncarew
Copy link
Contributor Author

@radicaled
Copy link
Contributor

Whoops -- I had a commit locally I didn't push for frappe. I've updated the fix_type_problems branch there.

@devoncarew
Copy link
Contributor Author

Yup, those are fixed as well now; just the two remaining from source_span.

@radicaled
Copy link
Contributor

Hm... looks like dev_compiler is also trying to compile packages linked to by dev_dependencies.

I'm not seeing this on 0.1.1+1, so I don't know if this is a regression in 0.1.4 or intended behavior.

Either way, https://github.com/radicaled/source_span/tree/fix_type_problems

It looks like dev_compiler's type inference isn't all that great yet:

 SourceSpan union(SourceSpan other) {
    if (other is! FileSpan) return super.union(other);

    var span = expand(other);
    var beginSpan = span._start == _start ? this : other as FileSpan;
    var endSpan = span._end == _end ? this : other as FileSpan;

    if (beginSpan._end < endSpan._start) {
      throw new ArgumentError("Spans $this and $other are disjoint.");
    }

    return span;
  }

The as FileSpan casts were needed even though there was a type guard at the beginning of the method.

@devoncarew
Copy link
Contributor Author

I think the negative !is doesn't trigger type promotion. There's a discussion here: dart-lang/tools#1612.

I'll patch that last git ref in -

@devoncarew
Copy link
Contributor Author

Cool! It all compiles (dartdevc -oweb/out web/entry.dart). I didn't try to run it; I'm guessing it'll take some work to stitch all the files together, or at least to get the first few bootstrapped (like referencing the dart_library.library module loading code). But the output looks much better than dart2js. For our app, it also compiles about 35% faster.

@tosh
Copy link

tosh commented Jul 30, 2015

Thanks for giving the dev compiler a try @devoncarew. Very exciting. 🍕 🎈

@devoncarew
Copy link
Contributor Author

Thanks! @radicaled did all the work. I'm excited to consume the output, probably once things are a bit further along.

@devoncarew
Copy link
Contributor Author

Closing this one; will open new issues against the newer version of ddc.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants