
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
80 lines
1.2 KiB
Plaintext
80 lines
1.2 KiB
Plaintext
== Why is this an issue?
|
|
|
|
In the constructor of a derived class, accessing ``++this++`` or ``++super++`` before ``++super()++`` is called raises a reference error. ``++super()++`` should always be called first.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
class Bar {
|
|
}
|
|
|
|
class Foo extends Bar {
|
|
constructor() {
|
|
this.val = 0; // Noncompliant
|
|
super();
|
|
}
|
|
}
|
|
|
|
class Foobar extends Foo {
|
|
constructor() {
|
|
super.val = 1; // Noncompliant
|
|
super();
|
|
}
|
|
}
|
|
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
class Bar {
|
|
}
|
|
|
|
class Foo extends Bar {
|
|
constructor() {
|
|
super();
|
|
this.val = 0;
|
|
}
|
|
}
|
|
|
|
class Foobar extends Foo {
|
|
constructor() {
|
|
super();
|
|
super.val = 1;
|
|
}
|
|
}
|
|
----
|
|
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Move this statement after the call to "super()" or remove it.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
Primary: Statement with "this." or "super."
|
|
|
|
Secondary: Call to "super()"
|
|
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== on 24 Jan 2017, 13:15:59 Yves Dubois-Pèlerin wrote:
|
|
This RSPEC is superseded by RSPEC-3854.
|
|
|
|
endif::env-github,rspecator-view[]
|