Make a valid error maker!

4

0

We've been twice challenged to make 'error quines' (see Make an error quine! and Make a slow error quine maker!), so why don't we try the opposite?

Instructions

  1. Write a "program" that, when run, produces an error.
  2. Copy the error message into a new program, and run it.
  3. Repeat Step 2 until the program runs without producing an error.

Rules

  • All of your programs must be run in the same language.
  • None of your programs can be shorter than 1 byte long.
  • The error(s) should be printed to STDERR.

Winning criteria

Your score is the number of programs run minus the length in bytes of your initial program. Highest score wins.


An example in monochrome TI-83+/84+ BASIC:

Initial program: {"
This creates a list with a string inside it, throwing an ERR:DATA TYPE.

Program 2: ERR:DATA TYPE
The space causes the interpreter to throw an ERR:SYNTAX.

Program 3: ERR:SYNTAX
The letters are treated as variable multiplication, and the colon as a newline. This runs successfully.

This chain's score is 3 (number of programs) minus 2 (length in bytes of {", the initial program), totaling 1.

M. I. Wright

Posted 2015-06-01T00:39:04.327

Reputation: 849

Question was closed 2018-09-01T02:39:55.443

This might be considered a duplicate of the slow error quine question, because the top answers there can be copied with slight modifications and become the top answers here.

– DLosc – 2015-06-01T01:29:56.260

@DLosc good point, as that's the case with both answers so far. I was going to add a rule that states Even if otherwise qualifies to win, your answer will not be accepted if it's a modification of an answer to the slow error quine thread, but that's not particularly objective; where do I draw the line at 'modification of'? – M. I. Wright – 2015-06-01T01:50:05.000

Yeah, I don't think a special-case rule of that nature is a good idea. You would need to either 1) change the description so that solutions to the first question intrinsically won't work here, or 2) change the scoring so that good solutions to the first question won't score well here. I don't know if there's a good way to do that without radically changing the concept, though. ("Must complete the sequence in X amount of time" was the first thing that came to mind, but then I'd just keep trying different numbers in my code until one was barely small enough.) – DLosc – 2015-06-01T01:59:32.500

(Normally, changing the rules after a question has been answered is frowned upon, but--speaking for myself--I wouldn't mind in this case, given the nature of the answers posted so far.) – DLosc – 2015-06-01T02:01:02.223

2(to anyone who thinks these aren't duplicate, the top two answers are both trivial ports of answers to the other question) – pppery – 2018-08-31T17:56:13.407

Answers

6

Pip 0.15.05.29, over 10100,000

(Subtracting the 51 bytes of source code is negligible for such a large number.)

This is a version of my answer to Make a slow error quine maker. Requires the -w flag for warning output.

i:5**6**7d:"i:1d: Ssi?dRo--iRsRPdx"Ssi?dRo--iRsRPdx

The exact number of steps depends only on the value assigned to i, so it could be arbitrarily large (until the Python interpreter runs out of memory). Also, it would take longer than the age of the universe to complete the above sequence.

Explanation:

Example here uses an i-value of 5 for purposes of explanation.

i:5d:"i:1d: Ssi?dRo--iRsRPdx"Ssi?dRo--iRsRPdx

After setting i, store a string in d and then attempt to execute the Swap statement. Swap expects two variables (more accurately, lvalues). s is fine, but the second expression is i?dRo--iRsRPdx. If i is true (nonzero, for our purposes), the ternary evaluates to dRo--iRsRPd, which uses d from earlier to form a near-quine--only with i decremented. This expression is not an lvalue, so Pip complains:

Attempting to swap non-lvalue i:4d:"i:1d: Ssi?dRo--iRsRPdx"Ssi?dRo--iRsRPdx

... which then starts the whole thing over again. (Attempting to swap non-lvalue is a bunch of no-ops: At calculates the ASCII value of t = 10, n-l subtracts newline minus each value of an empty list, and all the lowercase letters are just variables.)

The process continues in like fashion all the way down to:

Attempting to swap non-lvalue i:0d:"i:1d: Ssi?dRo--iRsRPdx"Ssi?dRo--iRsRPdx

When this is run, i is now false. The ternary expression evaluates to the else branch x--which is an lvalue. Thus, swap simply swaps the values of s and x. The program then exits with no output.

(The only thing that's changed from the previous answer is using x, which is a predefined variable, instead of a, which is undefined if there were no command-line arguments and thus triggers a different error when i gets down to zero.)

DLosc

Posted 2015-06-01T00:39:04.327

Reputation: 21 213

1

Bash, 9223372036854775809 - 75 = 9223372036854775734

This is a previous broken version of my answer to Make a slow error quine maker, which in fact works as what this question have specified.

a='"2>/dev/null;(((i=$((i-1)))>0))&&$(declare -p a)&&$a" #'
i=2**63
eval $a

It should be run with bash < file.sh, or use the same file name for each program, to get rid of the different file names in the error messages.

The first few errors are (with LANG=C):

bash: line 3: 2>/dev/null;(((i=9223372036854775807)>0))&&declare -- a="\"2>/dev/null;(((i=\$((i-1)))>0))&&\$(declare -p a)&&\$a\" #"&&"2>/dev/null;(((i=$((i-1)))>0))&&$(declare -p a)&&$a" #: No such file or directory
bash: line 1: 2>/dev/null;(((i=9223372036854775806)>0))&&declare -- a="\"2>/dev/null;(((i=\$((i-1)))>0))&&\$(declare -p a)&&\$a\" #"&&"2>/dev/null;(((i=$((i-1)))>0))&&$(declare -p a)&&$a" #: No such file or directory
bash: line 1: 2>/dev/null;(((i=9223372036854775805)>0))&&declare -- a="\"2>/dev/null;(((i=\$((i-1)))>0))&&\$(declare -p a)&&\$a\" #"&&"2>/dev/null;(((i=$((i-1)))>0))&&$(declare -p a)&&$a" #: No such file or directory

jimmy23013

Posted 2015-06-01T00:39:04.327

Reputation: 34 042

0

SmileBASIC, 2 - 6 = -4

Code must be run in the console so a line number isn't printed in the error message.

Initial program:

WHILE.

Program 2:

WHILE without WEND

12Me21

Posted 2015-06-01T00:39:04.327

Reputation: 6 110