Skip to content

getObject on list fails if offset is out of bounds #1948

@annagrin

Description

@annagrin

Currently getObject on list with an offset greater or equal than the list length fails with a JS stack trace from in debugger.getProperties when we call the sublist:

[FINE] AppInspector: getObject 8027075255564578089.1.77 failed:
Unexpected error from chrome devtools:
text: Uncaught
exception:
  preview: null
  description: Error: RangeError (start): Invalid value: Not in inclusive range 0..1001: 1002
    at Object.throw_ [as throw] (http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js:4745:11)
    at [dartx.sublist] (http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js:13063:21)
    at Object._checkAndCall (http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js:4948:16)
    at Object.callMethod (http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js:4991:17)
    at Object.dsendRepl (http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js:5000:17)
    at Array.<anonymous> (<anonymous>:9:29)
  type: object
  value: null
attempted JS eval: `        function (offset, count, end) {
          const sdk = require("dart_sdk");
          if (sdk.core.Map.is(this)) {
            const entries = sdk.dart.dload(this, "entries");
            const skipped = sdk.dart.dsend(entries, "skip", [offset])
            const taken = sdk.dart.dsend(skipped, "take", [count]);
            return sdk.dart.dsend(taken, "toList", []);
          } else  if (sdk.core.List.is(this)) {
            return sdk.dart.dsendRepl(this, "sublist", [offset, end]);
          } else {
            return this;
          }
        }
        `
stack trace:
throw_()          http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js 4744:10
[dartx.sublist]() http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js 13062:20
_checkAndCall()   http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js 4947:15
callMethod()      http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js 4990:16
dsendRepl()       http://localhost:52339/packages/build_web_compilers/src/dev_compiler/dart_sdk.js 4999:16
()                 8:28
:
#0      handleErrorIfPresent (package:dwds/src/utilities/server.dart:86:5)
#1      getResultOrHandleError (package:dwds/src/utilities/server.dart:98:3)
#2      AppInspector.jsCallFunctionOn (package:dwds/src/debugging/inspector.dart:250:9)
<asynchronous suspension>
#3      Debugger._subRange (package:dwds/src/debugging/debugger.dart:466:12)
<asynchronous suspension>
#4      Debugger.getProperties (package:dwds/src/debugging/debugger.dart:507:21)
<asynchronous suspension>
#5      InstanceHelper._listElements (package:dwds/src/debugging/instance.dart:315:45)
<asynchronous suspension>
#6      InstanceHelper._listInstanceFor (package:dwds/src/debugging/instance.dart:292:22)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions