sdk icon indicating copy to clipboard operation
sdk copied to clipboard

Update `StackOverflowError.stackTrace` documentation

Open sgrekhov opened this issue 4 months ago • 3 comments

The current StackOverflowError.stackTrace documentation reads:

The stack trace at the point where this error was first thrown.

Classes which extend Error will automatically have a stack trace filled in the first time they are thrown by a throw expression.

In fact, this property is always null for this class. See https://github.com/dart-lang/sdk/issues/28179 Looks like this documentation is a simply copy/paste from Error.stackTrace. Need to update it and reflect the fact that for the class StackOverflowError this property is always null.

P.S. "Classes which extend Error will automatically have a stack trace filled...". Dart API has no classes which extend Error, only bunch of classes which implements Error

sgrekhov avatar Feb 09 '24 08:02 sgrekhov

That's the wonder of inherited documentation. It's correct for Error itself, but subclasses that don't extend Error may want to change documentation.

The Dart API do have classes extending Error: AssertionError, ArgumentError, IndexError, NoSuchMethodError, RangeError, StateError, TypeError and UnimplementedError at least. (Every error defined in errors.dart except for StackOverflowError and OutOfMemoryError.)

lrhn avatar Feb 09 '24 17:02 lrhn

The Dart API do have classes extending Error

Ups, sorry. I read the documentation and it contains list of 'implementers' only and doesn't have list of 'Known subclasses' like Java API does. It misleaded me.

sgrekhov avatar Feb 12 '24 08:02 sgrekhov

This is probably the only place where it matters whether a class extends or implements a supertype, so it's unsurprising that DartDoc doesn't make the distinction.

lrhn avatar Feb 12 '24 08:02 lrhn