
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.
53 lines
759 B
Plaintext
53 lines
759 B
Plaintext
== Why is this an issue?
|
|
|
|
The contract and expectation of a ``++get++`` function is that it will return something. Failing to return a value on all paths is surely an error.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,javascript]
|
|
----
|
|
var x = {
|
|
_prop : "foo",
|
|
get prop(){ // Noncompliant
|
|
console.log("prop getter");
|
|
}
|
|
}
|
|
|
|
x.prop; // returns undefined
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,javascript]
|
|
----
|
|
var x = {
|
|
_prop : "foo",
|
|
get prop(){
|
|
console.log("prop getter");
|
|
return _prop;
|
|
}
|
|
}
|
|
|
|
x.prop; // returns "foo"
|
|
----
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
=== Message
|
|
|
|
Return a value from this function.
|
|
|
|
|
|
=== Highlighting
|
|
|
|
signature
|
|
|
|
|
|
endif::env-github,rspecator-view[]
|