# Find an Illegal String

The challenge is to find a string of characters that cannot appear in any legal program in your programming language of choice. That includes comments, strings, or other "non-executable" parts.

## Challenge

• Your program may be specific to a particular version or implementation of your language's compiler/interpreter/runtime environment. If so, please specify the particulars.
• Only standard compiler/interpreter/runtime options are permitted. You cannot pass some weird flag to your compiler to get a specific result (e.g. passing a flag to convert warnings into errors).
• If your programming language requires a specific encoding (e.g. UTF-8), your string must also be correctly encoded (i.e. strings which fail solely due to character decoding errors are not allowed).
• Every individual character in your submission must be admissible in a legal program; that is, you can't just use a character which is always rejected.
• The compiler/interpreter/runtime must give an error when given any source code that contains your string as a substring. The error does not have to be the same across programs - one embedding of your string might cause a syntax error, while another might cause a runtime error.

## Scoring

• Shortest illegal string for each language wins.
• You should explain why your string is illegal (why it cannot appear anywhere in a legal program).
• Dispute incorrect solutions in the comments. More specifically, you should provide a link to TIO or equivalent demonstrating a legal program (i.e. one that doesn't produce any errors) that contains the proposed substring.
• Some languages (e.g. Bash, Batch, Perl) allow arbitrary binary data to be appended to a program without affecting validity (e.g. using __DATA__ in Perl). For such languages, you may submit a solution that can appear only in such a trailing section. Make sure to make a note of that in your answer. (The definition of this "trailing section" is language-dependent, but generally means any text after the parser has entirely stopped reading the script).

## Example

In Python, I might submit

x
"""
'''


but this can be embedded into the larger program

"""
x
"""
'''
y
'''


• Can a counter-example rely on input from STDIN? – Zacharý Jul 20 '17 at 14:17
• Would this make a good CnR? – CalculatorFeline Jul 20 '17 at 16:59
• Too late now I guess, but it seems like this could have been a cops and robbers challenge. There's a lot of skill evident in the attempts to make valid programs, as well as coming up with the strings in the first place. – user2390246 Jul 21 '17 at 7:43
• My condolences to the Perl attempts. :) – Kaz Jul 23 '17 at 15:40
• In forth this seems nearly impossible, given the ability to overwrite effectively any word/symbol. I'm sure there are probably ways to do it by redefining core system words but nothing that couldn't appear after some code that backs those words up as other words first. – reffu Feb 14 '18 at 17:18

# Changeling, 2 bytes





That's two linefeeds. Valid Changeling must always form a perfect square of printable ASCII characters, so it cannot contain two linefeeds in a row.

The error is always a parser error and always the same:

This shape is unpleasant.


accompanied by exit code 1.

Try it online!

• This also works with 2Col. Try it online!. But the reason this breaks in 2Col is that every line needs to consist of exactly 2 characters, but the empty line breaks that. – Cows quack Jul 20 '17 at 6:10
• +1 because this is automatically the winner, since 1-byte solutions are not allowed because "you can't just use a character which is always rejected." – Zacharý Jul 20 '17 at 14:46
• @Cowsquack tfw I forgot about my own language – Skidsdev Jul 21 '17 at 10:54
• @Skidsdev tfw I re-forgot about my own language, and forgot about me forgetting about my own language – Skidsdev Nov 19 '18 at 18:19
• @Zacharý What about 0-byte solutions? – PyRulez Nov 19 '18 at 23:23

# Java, 4 bytes

;\u;


Try it online!

This is an invalid Unicode escape sequence and will cause an error in the compiler.

error: illegal unicode escape

• Doesn't work - one could have a string literal like "\\u;". – feersum Jul 20 '17 at 6:57
• @feersum Fixed at the cost of one byte – Cows quack Jul 20 '17 at 7:07
• Does this work for the /* and // comments? – TheLethalCoder Jul 20 '17 at 8:43
• @TheLethalCoder: Java preprocesses source code to alter \uXXXX escapes before doing anything else, so yes, this will work even inside comments.za – nneonneo Jul 20 '17 at 8:58
• I think this is the shortest Java answer in the history of this site still.. – Magic Octopus Urn Mar 2 '18 at 18:31

# JavaScript, 7 bytes


;*/\u)

• \u) is an invalid Unicode escape sequence and this is why this string is invalid
• Adding a // at the beginning will still not work because of the leading newline, leaving the second line uncommented
• Adding a /* will not uncomment the string completely because of the closing */ that completes it, leaving the \u) exposed
• As stated by @tsh, the bottom line can be turned into a regex by having a / after the string, so by having the ) in front of the \u, we can ensure that the regex literal will always be invalid
• As stated by @asgallant, one could do 1||1(string)/ to avoid having to evaluate the regex. The semi-colon at the beginning of the second line stops that from happening by terminating the expression 1||1 before it hits the second line, thus forcing a SyntaxError with the ;*.

### Try it!

clicky.onclick=a=>{console.clear();console.log(eval(before.value+"\n;*/\\u)"+after.value));}
textarea {
font-family: monospace;
}
<button onclick="console.clear();">Clear console</button>
<br>
<textarea id=before placeholder="before string"></textarea>
<pre><code>
*/\u)</code></pre>
<textarea id=after placeholder="after string"></textarea>
<br>
<button id=clicky>Evaluate</button>

• /* */\u0045 = 3 seems valid JavaScript code. – tsh Jul 20 '17 at 5:36
• 3 */\u;/ is still valid. – tsh Jul 20 '17 at 5:55
• Interesting to note that as of ES2018 (which won't be official until the end of this year) you can just wrap the whole thing in backticks due to this. You could probably fix this though just by inserting a backtick after the / (not that you need to fix it). (Also, the ; doesn't force the parsing of the bad regex, it forces a SyntaxError with the *.) – ETHproductions Jul 20 '17 at 15:28
• @Leushenko But this doesn't work against #if 0 as seen here: Try it online! – Cows quack Jul 21 '17 at 18:17
• In newer JS versions, String.raw with a template string can make this not break, because the invalid escape fails. Would be: String.rawcode here – iovoid Feb 14 '18 at 4:23

# COBOL (GNU), 8 bytes


THEGAME


First, a linefeed to prevent you from putting my word in a commented line.

Then, historically, COBOL programs were printed on coding sheets, the compiler relies heavily on 80-character limited lines, there are no multiline comments and the first 6 characters are comments (often used as editable line numbers), you can put almost anything there, AFAIK. I chose THEGAM at the beginning of the next line.

Then, the 7th symbol in any line only accepts a very restricted list of characters : Space (no effect), Asterisk (comments the rest of the line), Hyphen, Slash, there may be others, but certainly not E.

The error given by GnuCobol, for instance, is :

error: invalid indicator 'E' at column 7


Try it online!

Also, you just lost the game.

• Also, you just lost the game. I almost downvoted – Stephen Jul 21 '17 at 13:30

# Python, 10 bytes (not cpython)


?"""?'''?


Note the leading newline. Cannot be commented out due to the newline, and no combination of triple quoted strings should work if I thought about this correctly.

@feersum in the comments seems to have completely broken any cpython program on Windows as far as I can tell by adding the 0x1A character to the beginning of a file. It seems that maybe (?) this is due to the way this character is handled by the operating system, apparently being a translated to an EOF as it passes through stdin because of some legacy DOS standard.

In a very real sense this isn't an issue with python but with the operating system. If you create a python script that reads the file and uses the builtin compile on it, it gives the more expected behavior of throwing a syntax error. Pypy (which probably does just this internally) also throws an error.

### Edit:

Due to @feersum's diligence in finding obscure ways to break the Python interpreter, this answer is completely invalidated for any typical cpython environment as far as I can tell! (Python 2 and 3 for both Windows and Linux) I do still believe that these cracks will not work for Pypy on any platform (the only other Python implementation I have tested).

• @isaacg hmm, I actually did think of that but repl.it/JaHm/0 didn't work – KSab Jul 20 '17 at 5:10
• @isaacg Oh I didn't notice, on that site you have to click the debug tab to see that it does indeed produce an error. – KSab Jul 20 '17 at 5:12
• @officialaimm consider """?'''""" – KSab Jul 20 '17 at 5:20
• I made a program with this substring that runs on my machine. However, I think it does not run on many interpreters/platforms/versions. Can you specify which version of Python interpreter and OS this answer is targeting? – feersum Jul 20 '17 at 7:54
• Python 3 on Windows 7 happens to be exactly where my crack is working. Pastebin of base64-encoded program – feersum Jul 20 '17 at 18:19

# C (clang), 16 bytes

 */
#else
#else



Try it online!

*/ closes any /* comment, and the leading space makes sure we didn’t just start one. The newline closes any // comment and breaks any string literal. Then we cause an #else without #if or #else after #else error (regardless of how many #if 0s we might be inside).

• Cracked again. – feersum Jul 20 '17 at 7:18
• Also since C++11 raw strings seem to work, a solution is impossible with gcc. – feersum Jul 20 '17 at 7:22
• @feersum Huh, TIL that GCC accepts those in C code. I could specify -std=c99, but let’s try switching to clang. – Anders Kaseorg Jul 20 '17 at 7:28
• I'm really surprised that gcc accepts C++11 raw strings. Specifying the compiler version or implementation is perfectly OK, so if it's illegal in Clang, it's fair game. – nneonneo Jul 20 '17 at 17:29
• Can they close raw string again? @feersum – l4m2 Nov 1 '18 at 17:56

# Pyth, 6 bytes

¡¡$¡"¡  ¡ is an unimplemented character, meaning that if the Pyth parser ever evaluates it, it will error out with a PythParseError. The code ensures this will happen on one of the ¡s. There are three ways a byte can be present in a Pyth program, and not be parsed: In a string literal (" or .", which are parsed equivalently), in a Python literal ($) and immediately after a \.

This code prevents \ from making it evaluate without error, because that only affects the immediately following byte, and the second ¡ errors.

$ embeds the code within the $s into the compiled Python code directly. I make no assumptions about what might happen there.

If the program reaches this code in a $ context, it will end at the $, and the ¡ just after it will make the parser error. Pyth's Python literals always end at the next $, regardless of what the Python code might be doing. If the program starts in a " context, the " will make the string end, and the final ¡ will make the parser error. # Ada - 2 bytes I think this should work:  _ That's newline-underscore. Newline terminates comments and isn't allowed in a string. An underscore cannot follow whitespace; it used to be allowed only after letters and numbers, but the introduction of Unicode made things complicated. • Welcome to the site! :) – DJMcMayhem Jul 21 '17 at 16:57 # x86 32-bit machine code, 11 bytes (and future-proof 64-bit) 90 90 90 90 90 90 90 90 90 0f 0b  This is times 9 nop / ud2. It's basically a NOP sled, so it still runs as 0 or more nops and then ud2 to raise an exception, regardless of how many of the 0x90 bytes were consumed as operands to a preceding opcode. Other single-byte instructions (like times 9 xchg eax, ecx) would work, too. # x86 64-bit machine code, 10 bytes (current CPUs) There are some 1-byte illegal instructions in 64-bit mode, until some future ISA extension repurposes them as prefixes or parts of multi-byte opcodes in 64-bit mode only, separate from their meaning in 32-bit mode. 0x0e is push cs in 32-bit mode, but illegal on current CPUs (tested on Intel Skylake) in 64-bit. 0e 0e 0e 0e 0e 0e 0e 0e 0e 0e  Rules interpretation for executable machine code: • The bytes can't be jumped over (like the "not parsed" restriction), because CPUs don't raise exceptions until they actually try to decode/execute (non-speculatively). • Illegal means always raises an exception, for example an illegal-instruction exception. (Real programs can catch that with an exception handler on bare metal, or install an OS signal handler, but I think this captures the spirit of the challenge.) It works because a shorter byte-string ending in ud2 could appear as an imm32 and/or part of the addressing mode for another instruction, or split across a pair of instructions. It's easiest to think about this in terms of what you could put before the string to "consume" the bytes as part of an instruction, and leave something that won't fault. I think an instruction can consume at most 9 bytes of arbitrary stuff: a SIB byte, a disp32, and an imm32. i.e. the first 2 bytes of this instruction can consume 8 NOPs and a ud2, but not 9. c7 84 4b 00 04 00 00 78 56 34 12 mov dword [rbx+rcx*2+0x400],0x12345678  Can't beat 9 nops:  db 0xc7, 0x84 ; opcode + mod/rm byte: consumes 9 bytes (SIB + disp32 + imm32) times 9 nop ; 1-byte xchg eax, ecx or whatever works, too ud2 ---- b: c7 84 90 90 90 90 90 90 90 90 90 mov DWORD PTR [rax+rdx*4-0x6f6f6f70],0x90909090 16: 0f 0b ud2  64-bit mode:  c7 84 0e 0e 0e 0e 0e 0e 0e 0e 0e mov DWORD PTR [rsi+rcx*1+0xe0e0e0e],0xe0e0e0e 0e (bad)  But the bytes for 8 NOPs + ud2 (or times 9 db 0x0e) can appear as part of other insns:  db 0xc7, 0x84 ; defender's opcode + mod/rm that consumes 9 bytes times 8 nop ; attacker code ud2 times 10 nop ;; defenders's padding to be consumed by the 0b opcode (2nd half of ud2) ---- 18: c7 84 90 90 90 90 90 90 90 90 0f mov DWORD PTR [rax+rdx*4-0x6f6f6f70],0xf909090 23: 0b 90 90 90 90 90 or edx,DWORD PTR [rax-0x6f6f6f70] 29: 90 nop 2a: 90 nop ...  • The rules here weren't really clear enough for me to consider posting an asm/machine code answer. For example, why can't you just do ud2? It seems you're saying that you interpret the rules as forbidding jumping over the bytes, so ud2 would work just fine on its own, no? Oh…I guess you're saying the issue is that ud2 can appear as a prefix to a valid instruction? The second part of this answer was a little difficult for me to understand. – Cody Gray Jul 21 '17 at 6:02 • @CodyGray: Right, the 2 bytes that encode ud2 can appear in the imm32 of any instruction. I was thinking about this in terms of what bytes can you put before such a string that "consume" 0f 0b as part of an earlier instruction instead of decoding as ud2. I wasn't totally happy with how I ended up presenting it, but I wanted to illustrate why only 8 nops wasn't enough, and what happened with 9 nops + ud2. – Peter Cordes Jul 21 '17 at 7:58 • @CodyGray: An asm source program would be a totally different answer. That would have to error the parser used by the assembler, not produce faulting machine-code. So something like %else / %else might work to defeat %if 0, which can normally protect any invalid text from being parsed. (idea from a CPP answer) – Peter Cordes Jul 21 '17 at 8:02 • Don't quite satisfy. Your solution may be just in .data. (though it makes it impossible) – l4m2 Nov 1 '18 at 2:29 • @l4m2: To make the question answerable / interesting, I had to limit it to code that's executed (and not jumped over). See the rules interpretation bullet points in my answer. That would also rule out static data, of course. Because then it's not machine code at all, it's just data. This question required more adaptation than most for a machine-code answer to make sense, because there is no compile/assemble stage where you can error the parser, we're just talking about bytes already in memory. – Peter Cordes Nov 1 '18 at 2:38 # C#, 16 bytes  */" #endif<#@#> Works because: • // comment won't work because of the new line • /* comment won't work because of the */ • You can't have constants in the code alone • Adding #if false to the start won't work because of the #endif • The " closes any string literal • The <#@#> is a nameless directive so fails for T4 templates. • The new line tricks it so having / at the start won't trick the */ Each variation fails with a compilation error. • Weird that you decided to include T4 templates in your code. Isn't T4 considered a separate language? – Arturo Torres Sánchez Jul 20 '17 at 21:07 • @ArturoTorresSánchez I don't know I had never heard of them. Someone commented this didn't work when you included T4 templates so I added the fix. – TheLethalCoder Jul 21 '17 at 7:59 # APL and MATL and Fortran, 3 bytes  '  Newline, Quote, Newline always throws an error since block comments do not exist: • This applies to MATL too – Luis Mendo Jul 20 '17 at 7:39 • I think this would work in Fortran too. – Steadybox Jul 21 '17 at 2:27 # TI-BASIC, 2 bytes, cracked :-( : :▫  This is a newline followed by a ▫, which is a plotting symbol. Plotting symbols are only legal as arguments in plotting functions, or strings, which is impossible in this case because ▫ is prefaced with a new line. • What about :If 0:Then::▫:End – Timtech Jul 24 '17 at 17:09 • This is a bit of a nitpick and not pertinent to your solution, but since the leading colons are a UI element of the program editor and not part of the program itself, I don't think they should be reproduced here (i.e. only newline characters should be used as line separators). They could also be confusing to people who haven't written TI BASIC on the TI 83/84. – Jakob Aug 8 '17 at 15:43 • Yep, I doubt that there's a string illegal in any TI-Basic program, since you can skip even syntax errors with an If 0. – bb94 Mar 2 '18 at 2:31 # Free Pascal, 18 bytes  *)}{$else}{$else}  First close all possible comments, then handle conditional compile. Please comment here if I forgot something. • @user902383 Does your example contain the leading newline of his snippet? – Brian J Jul 20 '17 at 18:44 • @BrianJ nope, i thought it was just formatting issue, my bad – user902383 Jul 21 '17 at 9:23 • I don't think it's possible in Free Pascal. Just put them after begin end.. – jimmy23013 Jul 24 '17 at 15:28 • @jimmy23013 but it seems that codes after the end. become valid is allowed by the question. – tsh Jul 25 '17 at 1:13 ## Commodore 64 Basic, 2 bytes  B  (that's a newline followed by the letter "B"). Any line in a Commodore 64 program must begin with either a line number or a BASIC keyword, and stored programs only permit line numbers. There are no keywords beginning with "B" (or "H", "J", "K", "Q", "X", "Y", or "Z"). • If I append =0 then this just becomes an assignment statement... – Neil Jul 21 '17 at 9:54 • @Neil, that would be a valid immediate-mode command, but not a valid program. – Mark Jul 21 '17 at 10:05 # Brain-Hack (a variation of Brain-Flak), 3 2 bytes Thanks to Wheat Wizard for pointing out that Brain-Hack doesn't support comments, saving me a byte. (}  Try it online! • How do you do comments in Brain-Flak? I don't know of any way to do those. – Erik the Outgolfer Jul 20 '17 at 18:26 • @EriktheOutgolfer # TIO – Riley Jul 20 '17 at 18:27 • Huh undocumented behavior. – Erik the Outgolfer Jul 20 '17 at 18:29 • @EriktheOutgolfer I always assumed they were documented somewhere. I'll look at adding them. – Riley Jul 20 '17 at 18:34 • You don't need the newline in BrainHack or Craneflak, Rain-Flak is the only one of the three versions that has line comments. Although Craneflak parses on the fly so its impossible to solve this in Craneflak, any solution could be beaten by prepending (()){()}. – Sriotchilism O'Zaic Aug 7 '17 at 23:26 # Literate Haskell, 15 bytes Repairing a deleted attempt by nimi.  \end{code} 5 >  Try it online! nimi's original attempt is the last two lines, based on Literate Haskell not allowing > style literate code to be on a neighboring line to a literate comment line (5 here). It failed because it can be embedded in a comment in the alternate ("LaTeX") literate coding style: $$\begin{code} {- 5 > -} \end{code}$$  However, the $$\begin{code}$$ style of Literate Haskell does not nest, neither in itself nor in {- -} multiline comments, so by putting a line with \end{code} just before the line with the 5, that workaround fails, and I don't see a different one. # CJam, 7 bytes "e#" :"  Try it online! # Logicode, 10 bytes  var A A()  Try it online! Newline prevents commenting the variable declaration. Results in TypeError: 'list' object is not callable and we aren't able to define a lambda expression A() to make this valid code (will still throw the same error). circ A>  Looks like it might work, but unfortunately, we can define vars A and circ that make this valid: var A=0 var circ circ A>  • Cracked. – feersum Jul 26 '17 at 6:31 • @feersum Oh hey, nice job. – Draco18s Jul 26 '17 at 12:54 • @Draco18s I think feersum meant that this answer is invalid. – Erik the Outgolfer Mar 23 '18 at 21:36 • @EriktheOutgolfer He cracked it, thus my answer is invalid? Yes, I suppose, but I couldn't find a way to make it valid after that and have no interest in doing so now, nine months later. Logicode is not a language I am very familiar with. I was congratulating him on proving my answer wrong. – Draco18s Mar 24 '18 at 1:46 # VBA, 2 Bytes A linefeed followed by an underscore - the _ functions as the line continuation character in VBA, and as there is nothing in the line directly to the left or above the line continuation, coupled with VBA's lack of multiline comments means that this will always throw the compile time error Compile Error: Invalid character  _  • You do depend on your pattern starting on a new line... so, add a newline. – Deduplicator Jul 20 '17 at 19:18 • @Deduplicator it already has a new line, - it does not matter what follows the _, only that there is no valid line to the left or above it – Taylor Scott Jul 20 '17 at 19:48 • What if it is embedded like this: myfunction( \n_ )? – Deduplicator Jul 20 '17 at 20:00 • @Deduplicator the line continuation character must be on the same line as it is continuing ie Public Function Foo( ByVal bar as Integer, _  (new line) bas as long) as double - so yes, it would result in an error if you called the function you described – Taylor Scott Jul 20 '17 at 21:00 • Ok, in that case it's more like myfunction( _ \n_ ). Sorry for the confusion. To put it another way, you should have used two newlines. – Deduplicator Jul 20 '17 at 21:34 # AWK, 3 bytes  /  Try it online! Since AWK doesn't have a method to do multi-line comments, need newline before and after / to prevent commenting out or turning this into a regex, e.g. add 1/. The most common message being unexpected newline or end of string. • I think he intended for the newline to come before the slash – Skidsdev Jul 21 '17 at 11:25 • I think I need newlines before and after. That's what I get for posting when tired. – Robert Benson Jul 21 '17 at 15:43 • Cracked. – feersum Jul 22 '17 at 5:14 • If I add enough newlines in there, I'm sure it'll break... not sure if there's anything more clever I could do. :( – Robert Benson Jul 23 '17 at 15:20 # Fortran, 14 bytes  end program e  No multiline comments or preprocessor directives in Fortran. • Is there a good way to test this online? Also, which version/compiler of Fortran? – Robert Benson Jul 23 '17 at 15:21 # R (base package), 6 7 bytes  %"'%  Note leading newline and trailing space. One character (backtick) added to prevent the crack that @Giuseppe found, which involves creating a weird function name such as % %. From experimenting, it appears that a backtick cannot appear in such a name without breaking things. I fully expect to be proven wrong though! Other important features: • Newline prevents commenting it out • % is a special character that only appears in certain commands such as %% and %in%. As far as I know it can't be followed by a space (except in a function name, see above) or a string • If both % characters are contained inside quotes, that gives two consecutive quoted strings with no separator, which yields an error. (There may well be packages out there that might make valid code out of this, so this only applies to the base package.) <- Actually, thinking about it, this probably isn't true. I think packages are all built on R code, so if it can be in a package, it can be coded from scratch. • Nice idea, but this cracks it. – Giuseppe Jul 20 '17 at 11:52 • Heck, that even works without quote – Giuseppe Jul 20 '17 at 12:01 • @Giuseppe Clever! I forgot about backquotes. Will have to revisit this when I have the time. Maybe a carefully placed backquote in the string might fix it. – user2390246 Jul 20 '17 at 12:31 • Maybe \n%"'(backquote)"'% ? – Giuseppe Jul 20 '17 at 16:30 • This is a tough language for this challenge. Currently, if you precede this code with ‘\n%"'‘ = 1; ‘% %‘ = c; ‘ (replace the ‘s with backticks) and follow it with % 1 it runs fine. – rturnbull Jul 22 '17 at 21:26 ## C (GCC), 7 bytes Has been broken, can't think of anything else that's not already been submitted.  */)"#  \*/ - Stops you from inserting /* before it )" - Stops this: \# - Causes the following error stray ‘#’ in program You shouldn't be able to #define # because that will give an error. I am using GCC 6.4.0. The lack of a semicolon after )" will cause an error even if you append a valid preprocessor statement after #. • ... there is // lol – HyperNeutrino Jul 21 '17 at 0:06 • Inserting 2 newlines before the current snippet should actually stop // from working (1 doesn't work because you can backslash escape it) – Value Ink Jul 21 '17 at 0:09 • Welcome to PPCG! Very nice first submission. If you restrict your answer to Clang (like the other C answer), I think you can cut this down to 5 bytes (removing the )" part). – Steadybox Jul 21 '17 at 2:32 • You can't work around raw strings as they take arbitrary delimiters. Example. – feersum Jul 21 '17 at 4:17 • Also, you can just #if 0 the entire thing. – Anders Kaseorg Jul 21 '17 at 4:53 # Taxi, 4 5 bytes '"]'"  Fixed with help in comments from EngineerToast. I believe this works correctly. '" terminates any strings we are in and ] terminates any comments we are in. Taxi does not allow inline comments (comments must start as the first character in a line) so this code must always be prepended by \n[. After \n[<comment>], '" again makes sure that the first '" ended a string, so the second '" starts a string, which is invalid directly after a comment. • '"]:' is waiting at Writer's Depot. is valid. Try just '"'" – Engineer Toast Jul 20 '17 at 15:51 • @EngineerToast oh, right, I'm dumb. But then you have ['"'"] I think – Stephen Jul 20 '17 at 15:53 • Good point. '"]'" is the combination of both, I think. – Engineer Toast Jul 20 '17 at 15:54 • @Zacharý the comment is that I have to add (non-breaking) spaces around it for it to look right – Stephen Jul 20 '17 at 16:05 • Cracked. – feersum Jul 24 '17 at 3:16 # SmileBASIC, 2 bytes  !  Nothing continues past the end of a line, so all you need is a line break followed by something which can't be the start of a statement. ! is the logical not operator, but you aren't allowed to ignore the result of an expression, so even something like !10 would be invalid (while X=!10 works, of course) Similar things will work in any language where everything ends at the end of a line, as long as it parses the code before executing it. There are a lot of alternative characters that could be used here, so I think it would be more interesting to list the ones that COULD be valid. @ is the start of a label, for example, @DATA; ( could be part of an expression like (X)=1 which is allowed for some reason; any letter or _ could be a variable name X=1, function call LOCATE 10,2, or keyword WHILE 1; ' is a comment; and ? is short for PRINT. • oh, for some reason when I edited the post it was duplicated... – 12Me21 Mar 1 '18 at 20:11 # JavaScript (Node.js), 9 8 bytes */ \u~  Try it online! I think this should be illegal enough. ## Previous JS attempts in other answers  ;*/\u)  By @Cows quack As an ES5 answer this should be valid, but in ES6 wrapping the code with a pair of backticks wrecks this. As a result valid ES6 answers must involve backticks.  */}'"\u!  By @iovoid This is an improved version involving backticks. However a single / after the code breaks this (It becomes a template literal being multiplied by a regex, useless but syntactically valid.) @Neil made a suggestion that changing ! to ). This should theoretically work because adding / at the end no longer works (due to malformed regex.) ## Explanation */ \u~  This is by itself illegal, and also blocks all single and double quotes because those quotes cannot span across lines without a \ at the end of a line //*/ \u~  and /**/ \u~  */ \u~  Blocks initial backtick by introducing non-terminated RegExp literal console.log*/ \u~  Blocks tagged template literals by introducing an expected operator between two backticks # Rockstar, 4 5 bytes Crossed out 4 is still 4 :( ) """  Rockstar is a very... wordy language. While " can be used to define a string, such as Put "Hello" into myVar, to my knowledge there is no way for 3 quotes to appear outside of a comment, and the close paren ensures that won't happen either (Comments in Rockstar are enclosed in parentheses, like this). Rockstar also has a poetic literal syntax, in which punctuation is ignored, so the newline makes sure that the 3 quotes are the start of a line of code, which should always be invalid • What about (()"""), wouldn't that be a no-op? – BMO Nov 21 '18 at 23:46 • @BMO first paren opens a comment, 2nd paren does nothing because it's commented, 3rd paren closes the comment, then you have """) being parsed as code, which is invalid – Skidsdev Nov 22 '18 at 1:20 • Hmm, nested comments are not in the specs. Comments seem to be discouraged anyways. But you oversaw poetic string literals which allow any string, so Goethe says )""" is valid. – BMO Nov 22 '18 at 17:13 • @BMO good point, can be fixed by inserting a newline inbetween ) and """ – Skidsdev Nov 23 '18 at 18:21 # Powershell, 10812141314 16 bytes -2 byte thanks to Mazzy finding a better way to break it +4 -1 bytes thanks to IsItGreyOrGray $#>
'@';
"@";
@=


I hope this works. ' and " to guard against quotes, #> to break the block-comment, new lines to stop the single-line comment, both '@ and "@ to catch another style of strings, and then starts an improper array to throw a syntax error.

The logic being they can't use either set of quotes to get in, they can't block-comment it out, If @" is used, it'll create a here-string which can't have a token afterwards, and if they leave it alone, it'll try to make a broken array. This statement wants to live so hard, I keep finding even more holes in the armor.

• Or protectors + @= – mazzy Nov 19 '18 at 22:26
• @IsItGreyOrGray AAAAAAAAAAAw heck. – Veskah Jan 25 at 21:12
• It looks like changing #> to \$#> will break it as "not recognized as the name of a cmdlet..." It might be made legal again somehow, but I don't have a way. Yet. :) – IsItGreyOrGray Jan 25 at 21:38
• @IsItGreyOrGray Sonofagun. Now featuring semi-colon armor? – Veskah Jan 25 at 23:06
• Nice! I've got nothing. Everything I've tried has failed. – IsItGreyOrGray Jan 28 at 14:31

# S.I.L.O.S, 4 bytes

Silos is competitive \o/


x+



S.I.L.O.S runs on a two pass interpreter / compiler. Before execution a "compiler" attempts to simplify the source into an array describing the sourc Each line is treated separately. x+a is an assignment operator that will add ea to the value of x and store it into x. However the "compiler" will break. Therefore, we take this string and add a new line before and after ensuring it's on its own line and breaks the compiler.

Try it online!

• Why doesn't ax+ error out? – Erik the Outgolfer Jul 20 '17 at 18:40
• undefined compiler behavior @EriktheOutgolfer – Rohan Jhunjhunwala Jul 20 '17 at 19:27

# Whitespace, 7 bytes, CRACKED





Try it online!

I'm using the original interpreter written in Haskell. One other interpreter I tried online seemed to have no errors at all, but just hung on invalid input.

For you visual folks, that's [LF][LF][Tab][LF][Tab][LF][LF].

If the start of this code is not in an opcode, number, or label, [LF][LF][Tab] is not a valid opcode.

The first [LF] may be the end of a number, a label, a [Space][LF][LF] (Pop) opcode, a [Tab][Space][Space][LF] (Multiply) opcode, a [LF][Tab][LF] (Return) opcode, or a [LF][LF][LF] (Exit) opcode. But then [LF][Tab][LF] is the Return opcode, followed by [Tab][LF][LF], which is not a valid opcode.

The first [LF] may be the end of a [Space][Tab][LF] (Slide) opcode, followed by the invalid number argument [LF], but then [Tab][LF][Tab][LF] is not a valid opcode. (And today I learned this interpreter considers using the invalid [LF] in place of a number a successful parse at first, and due to Haskell's lazy evaluation, you only get an error if you actually attempt to use it in a way that requires a numeric value, which is easily avoided with a jump.)

The first [LF] may be the end of a [LF][Space][LF] (Jump) opcode, followed by the trivial label [LF], but then [Tab][LF][Tab][LF] is not a valid opcode.

The first two [LF][LF] may be the end of a [Space][LF][LF] (Pop) opcode or a [LF][LF][LF] (Exit) opcode, but then [Tab][LF][Tab][LF]` is not a valid opcode.

That covers all the possible overlaps with the start of my string.

• Cracked. – feersum Jul 25 '17 at 2:49
• Oh, wow, the parsing is lazy too. I probably should have tried that. Not possible, then. (Maybe there's another interpreter where this answer would be correct, but whatever.) – aschepler Jul 25 '17 at 11:46