Saturday, October 26, 2013

Several Dart bugs I encountered => found how to avoid the problem

The problem I reported in the previous post was really annoying.
It caused bunch of strange problems and there was no clue for the real reason why import fail, why 'a is A' does not have expected value.
The actual fix was to change return type of get listeners from List<ComponnetAction> to List<RowAction>. these types are defined by typedefs. After this change, everything got normal .
  
typedef void ComponentAction(Event event, Component c);
typedef void RowAction(Event event, Row row);

// this caused the problem:
//List<ComponentAction> get listeners => table.row_listeners;

// shoudl use this instead.
List<RowAction> get listeners => table.row_listeners;

Such a subtle difference caused a lot of strange problems without any meaningful error messages. Actually, the main bug may be the failed handling of ComponentAction, but even if it cannot be used there, Dart should report such error so that it can be corrected easily. 

I was a bit feeling not to use Dart if the quality of system is such low.
In facts, there were other bugs which is quite disappointing to know  the level of quality control of bug fixes.

1) wrong type of methods for reflect(new List<A>()).type,

{
    ClassMirror cmirr = reflect(new List()).type;
    print(">>0@@ cmirr.reflectedType: ${cmirr.reflectedType}");
    cmirr.getters.forEach((k, MethodMirror md){
      Type tm = null;
      if (md.returnType is ClassMirror) {
        tm = (md.returnType as ClassMirror).reflectedType;
        print(">>1@@ k: ${k}, tm: ${tm}");
      } else if (md.returnType is TypeVariableMirror) {
        TypeVariableMirror tvmirr = md.returnType;
        print(">>2@@ tvmirr: ${tvmirr.runtimeType}");
      }
    });
  }

The result of executing this is:

>>0@@ cmirr.reflectedType: List<A>
>>1@@ k: Symbol("length"), tm: int
>>1@@ k: Symbol("_capacity@0x36924d72"), tm: int
>>1@@ k: Symbol("first"), tm: A
>>1@@ k: Symbol("last"), tm: A
>>1@@ k: Symbol("single"), tm: A
>>1@@ k: Symbol("isEmpty"), tm: bool
>>1@@ k: Symbol("isNotEmpty"), tm: bool
>>1@@ k: Symbol("reversed"), tm: Iterable<T>
>>1@@ k: Symbol("iterator"), tm: Iterator<T> 

This issue was discussed with Gilad, and he told me Google team is working on this issue. At the time, first 's type was not substituted to A, this issues was definitely fixed.
But the type parameter of the generic type of  reversed an iterator is still T, not substituted to A.
These type related implementation is quite basic, must have highest quality.
Although they fixed, the way to fix without addressing all problem was very sloppy.
I reported this issue, but they looks not setting higher priority.

2) Another case was dart2js bug, which crashed dart2js. For this issue I observed the same problem after they 'fixed' the issue, but  they could not fix all the cases. Although the response time and fixed time was good, related issued should be checked when one issue was reported.(take more time to examine related issues rather than fixing fast)

3) the reflectClass behavior is really bad. and alternative way to get runtimeType though instantiating object is just absurd.
These things indicate the design of mirror is not well guided.
They may be busy for many stuff, but some basic language core thing should be implemented in highest quality.

My impression is Dart team is too much focusing on Polymer.
Often such politically overselling approach is proved to be misguiding/useless in the end, but it will waste a lot of people's energy and time.

No comments:

Post a Comment