Open dstaley opened 5 years ago
Today when using the coverage library to check test coverage on a library I'm writing, I ran into the following error:
coverage
NoSuchMethodError: The method 'map' was called on null. Receiver: null Tried calling: map<List<int>>(Closure: (dynamic) => List<int>) dart:core Object.noSuchMethod package:vm_service_client/src/script.dart 181:14 new VMScript._ package:vm_service_client/src/script.dart 62:11 VMScriptRef.load ===== asynchronous gap =========================== dart:async _AsyncAwaitCompleter.completeError package:vm_service_client/src/script.dart VMScriptRef.load ===== asynchronous gap =========================== dart:async _asyncThenWrapperHelper package:vm_service_client/src/script.dart VMScriptRef.load package:coverage/src/collect.dart 85:30 _getCoverageJson ===== asynchronous gap =========================== dart:async _asyncThenWrapperHelper package:coverage/src/collect.dart _getCoverageJson package:coverage/src/collect.dart 51:26 _getAllCoverage ===== asynchronous gap =========================== dart:async _asyncThenWrapperHelper package:coverage/src/collect.dart _getAllCoverage package:coverage/src/collect.dart 35:18 collect ===== asynchronous gap =========================== dart:async _asyncThenWrapperHelper package:coverage/src/collect.dart collect /Users/dylanstaley/.pub-cache/hosted/pub.dartlang.org/coverage-0.12.3/bin/collect_coverage.dart 22:26 main.<fn>
I did a bit of digging, and the error comes from this line:
VMScript._(Scope scope, Map json) : klass = newVMClassRef(scope, json["class"]), size = json["size"], library = newVMLibraryRef(scope, json["library"]), source = json["source"], _tokenPositions = (json["tokenPosTable"] as List) // <<<< .map((sublist) => (sublist as List).cast<int>()) .toList(), super._(scope, json);
I found where the json Map was coming from and added a print statement. Sure enough, the Map doesn't have a tokenPosTable key:
json
print
tokenPosTable
{ type: Script, class: { type: @Class, fixedId: true, id: classes/13, name: Script }, size: 112, id: objects/32, uri: org-dartlang-sdk:///runtime/lib/string_buffer_patch.dart, _kind: kernel, _loadTime: 1545336218821, lineOffset: 0, columnOffset: 0 }
I'm a good bit out of my comfort zone with this one, but if there's any info I can provide that would be helpful please let me know!
Today when using the
coverage
library to check test coverage on a library I'm writing, I ran into the following error:I did a bit of digging, and the error comes from this line:
I found where the
json
Map was coming from and added aprint
statement. Sure enough, the Map doesn't have atokenPosTable
key:I'm a good bit out of my comfort zone with this one, but if there's any info I can provide that would be helpful please let me know!