A Fragile Quine
A fragile quine is a quine that satisfies the property of having each substring made by removing a single character, when evaluated, produces an error.
For example. If your program asdf
is a quine, then for it to be fragile, the following programs must error:
sdf
adf
asf
asd
Your program (and all of its substrings) must be fully deterministic, and must be in the same language. A program falling into an infinite loop (that is, failing to terminate), even if not eventually producing an error is considered to "produce an error" for the purposes of this challenge.
Standard loopholes apply, including the usual quine restrictions (e.g. not able to read own source code).
For example, print("foo")
is not fragile. All these substrings must error:
rint("foo")
pint("foo")
prnt("foo")
prit("foo")
prin("foo")
print"foo")
print(foo")
print("oo")
print("fo")
print("fo")
print("foo)
print("foo"
The ones that don't error are:
print("oo")
print("fo")
print("fo")
So it is not fragile.
An important note on quines
By consensus, any possible quine must satisfy this:
It must be possible to identify a section of the program which encodes a different part of the program. ("Different" meaning that the two parts appear in different positions.)
Furthermore, a quine must not access its own source, directly or indirectly.
Example
Since I consider JavaScript's function#toString to be "reading it's own source code", I am disallowing it. However, if I weren't to bar it, here is a fragile quine in JavaScript:
f=(n=b=`f=${f}`)=>(a=(n)==`f=${f}`,n=0,a)&(n!=b)?b:q
Tester
Here is a program that, given the source code of your program, generates all programs that must error.
let f = (s) =>
[...Array(s.length).keys()].map(i =>
s.slice(0, i) + s.slice(i + 1)).join("\n");
let update = () => {
output.innerHTML = "";
output.appendChild(document.createTextNode(f(input.value)));
};
input.addEventListener("change", update);
update();
#output {
white-space: pre;
}
#input, #output {
font-family: Consolas, monospace;
}
<input id="input" value="print('foo')">
<div id="output"></div>