# How is a single tilde parsed?

How is a~b parsed and evaluated? I would expect an error, but it goes through without any complaints, yielding no apparent output. At first I thought it evaluated to Null, but then I realized every expression I've tried containing a~b (either directly or through something like %) gives no output whatsoever. Consider the following:

a~b
a~b//FullForm
Trace[a~b]
{A, a~b, B}
(a~b)~c


Each of the above (even input in separate cells) gives no output whatsoever.

Context: I accidentally typed A ~f[##,...]&~ B and was surprised by the result. (To be clear, I understand the precedence issue; what's surprising to me is the handling of (A~f[##,...])&.)

Edit 2

Thanks to Carl Woll (and later Szabolcs), I now know for sure that a~b is a syntax error. But my true problem was this: the front end didn't tell me it was a syntax error.

At Carl Woll's urging, I realized Messages[Syntax] returned

{HoldPattern[Syntax::bktwrn]:>"1" represents multiplication; use "2" to represent a function4.}


rather than the expected

{HoldPattern[Syntax::bktwrn]:>"1" represents multiplication; use "2" to represent a function4.,
HoldPattern[Syntax::tsntxi]:>"1" is incomplete; more input is needed.4}


I.e., Syntax::tsntxi was nowhere to be found!

Later I realized that in a fresh kernel, a~b is properly recognized as a syntax error. Before I restarted the kernel, I noticed something interesting: even Plot[x] failed to give me Plot::argr (Plot called with 1 argument; 2 arguments are expected) warning.

Reevaluating the notebook does not reproduce the error. There must have been some funny business somewhere in the session that later got erased. This is fortunate, as my problem is effectively resolved, even if my curiosity isn't.

It seems that somewhere in the (long) notebook I was working in, MMA stopped showing me certain messages, and stopped recognizing certain syntax errors. Without access to the session, it's nigh impossible to say more.

Lastly I offer an apology, for had I simply tested a~b in a fresh kernel, I wouldn't have wasted everyone's time trying to figure out the true problem. I sincerely thank everyone who viewed and thought about my problem, especially Carl Woll. At the very least, I learned some things about how MMA handles syntax errors in the process. (This is why I will accept Carl Woll's answer.) Of course, I also learned my lesson: always test in a fresh kernel!

Edit 1

At Carl Woll's request, here's raw call data:

Cell[BoxData[
RowBox[{"a", "~", "b"}]], "Input",
CellChangeTimes->{{3.69637095440485*^9, 3.6963709556847563*^9}}]


And here's the output of CurrentValue[{StyleDefinitions, "Input"}]

{CellMargins -> {{66, 10}, {5, 10}},
StyleKeyMapping -> {"=" -> "WolframAlphaShort", "*" -> "Item"},
Evaluatable -> True, CellGroupingRules -> "InputGrouping",
TextClipboardType -> "InputText", StripStyleOnPaste -> True,
PageBreakWithin -> False, GroupPageBreakWithin -> False,
DefaultFormatType -> DefaultInputFormatType,
FrontEndCopySpecial["PlainText"]],
KernelExecute[ToExpression["FrontEndCopyAsTeX[]"]],
KernelExecute[ToExpression["FrontEndCopyAsMathML[]"]],
FrontEndCopySpecial["CellExpression"]],
FrontEndCopySpecial["NotebookExpression"]]}], Delimiter,
"EvaluateInitialization"],
"SelectionConvert" -> InputForm],
FrontEndExecute[{FrontEndNotebookOpen["SpecialCharacters.nb"]}]],
KernelExecute[ToExpression["FEtoggleComment[]"]],
MenuItem["&Get Help", FrontEndSelectionHelpDialog[True]],
FrontEndExecute[{FrontEndNotebookOpen[
FrontEndFindFileOnPath["WhyTheColoring.nb",
"PrivatePathsSystemResources"]]}]],
FrontEndExecute[
FrontEndValue[FEPrivateNotebookToggleFullScreen[]]]]},
ShowAutoStyles -> True, ShowAutoConvert -> True,
"TranslationOptionsContentEnabled" -> Automatic,
"HyphenationOptionsHyphenationCharacter" -> "\[Continuation]",
AutoItalicWords -> {}, AutoQuoteCharacters -> {},
PasteAutoQuoteCharacters -> {}, LanguageCategory -> "Input",
FormatType -> InputForm, NumberMarks -> True,
LinebreakAdjustments -> {0.85, 2, 10, 0, 1},
CounterIncrements -> "Input", MenuSortingValue -> 1500,
MenuCommandKey -> "9", FontSize -> 13, FontWeight -> "DemiBold"}

• Don't you get a little yellow box on a red bracket indicating a syntax error? – Carl Woll Feb 18 '17 at 1:14
• @CarlWoll Nope, nothing. I'm in v11.0.0. – jjc385 Feb 18 '17 at 1:15
• You get no output because it is a syntax error. I don't know why you don't get an indication of that in your version, though. – Carl Woll Feb 18 '17 at 1:16
• @CarlWoll Does your version behave differently? – jjc385 Feb 18 '17 at 1:18
• Could you include the underlying Cell structure (Cell | Show Expression or Shift Cmd E on a Mac), and the output of CurrentValue[{StyleDefinitions, "Input"}] as well what style sheet you're using? – Carl Woll Feb 18 '17 at 1:23

I only have a partial answer. The input a~b is not syntactically correct, and so the input is not evaluated. One way to see that it is not syntactically correct is to use:

ToExpression[RowBox[{"a","~","b"}],StandardForm]


ToExpression::esntx: Could not parse RowBox[{a,~,b}] as input.

$Failed or SyntaxQ["a~b"]  False It should be equivalent to an input like 1/ which is incomplete. One signature of invalid syntax is that the line number does not go up when you evaluate the expression. When an invalid syntax is encountered, the Cell should acquire an EmphasizeSyntaxErrors option, and below is the Cell expression that I see after using Cell | Show Expression to look at the cell: Cell[BoxData[ RowBox[{"a", "~", "b"}]], "Input", CellChangeTimes->{{3.696372835096594*^9, 3.696372836088888*^9}}, EmphasizeSyntaxErrors->True] The Cell given by the OP doesn't have this option, and so it doesn't get a red bracket. Further diagnosis is out of my realm, sorry. It just occurred to me that one way to get the behavior the OP noticed is to do: Off[Syntax::tsntxi]  • +1 for teaching me a bit about syntax errors. Note that for me, your ToExpression example evaluates to $Failed but does not generate an error. – jjc385 Feb 18 '17 at 2:35
• What does Syntax::tsntxi return? – Carl Woll Feb 18 '17 at 2:41
• Syntax::tsntxi returns MessageName[Syntax,"tsntxi"]. Am I misinterpreting your question? – jjc385 Feb 18 '17 at 2:44
• Perhaps this is useful: Messages[Syntax] returns {HoldPattern[Syntax::bktwrn]:>"1" represents multiplication; use "2" to represent a function4} -- Syntax::tsntxi is absent! – jjc385 Feb 18 '17 at 2:55
• If you haven't already, please see edit 2 to the question. Thanks a lot for your help -- I'm somewhat ashamed that I didn't test in a fresh kernel before asking and wasting some of your time. Your answer helped a lot; hence the accept. – jjc385 Feb 19 '17 at 18:42

When there is a syntax error, a yellow [+] box will appear next to cell bracket after you try to evaluate:

If your window is very wide and you don't look on the right edge, you will not notice it.

Clicking it reveals the error:

A complete input would be a ~b~ c`.