7
$\begingroup$

Bug introduced in V10 and partially fixed in V11.1.1


TLDR

Various of expressions which have fancy typeset form or are designed as UI elements won't survive ToExpression @* ToBoxes round-trip. And they should.

Examples

  • InterpolatingFunction (new)

    MakeExpression[#, StandardForm] & @ ToBoxes @ Interpolation[
        {{0, 0}, {1, 1}, {2, 3}, {3, 4}, {4, 3}, {5, 0}}
    ] // Shallow
    
    ErrorBox[ErrorBox[TagBox[<<5>>]]]
    

    ToExpression::esntx: Could not parse TagBox[<<1>>] as input.

  • InputField

    ToExpression @ ToBoxes @ InputField[Dynamic[x]]
    
     $Failed
    

    ToExpression::notstrbox: InputFieldBox[x] is not a string or a box. ToExpression can only interpret strings or boxes as Wolfram Language input.

    I don't expect InputField[Dynamic[x]] but at least something which is a proper expression, e.g. button works:

    ToExpression @ ToBoxes @ Button[Dynamic[x]] // InputForm
    
    Button[Dynamic[x], Evaluator -> None, Appearance -> Automatic, Method -> "Preemptive"]
    

    Things get weirder, MakeExpression can handle InputField case:

    InputForm @ MakeExpression[
        #,
        StandardForm
    ] & @ ToBoxes @ InputField[Dynamic[x]]
    
    HoldComplete[InputField[Dynamic[x]]]
    
  • FileNameSetter

    InputForm@MakeExpression[
      #,
      StandardForm
    ] & @ ToBoxes @ FileNameSetter[Dynamic[x]]
    
    ErrorBox[RowBox[{"FileNameSetterBoxes", "[", ErrorBox[Dynamic[x]], ",", "Open", ",", All, "]"}]]
    

    Syntax::sntxf: "FileNameSetterBoxes[" cannot be followed by "x,Open,All]".

Question

Are those bugs or have I missed something. Please help me understand that. :)


related

ToExpression and ToBoxes aren't inverses of each other?

How to make RawBoxes to be Expression

$\endgroup$
6
  • 1
    $\begingroup$ x = Dynamic[y]; MakeExpression@MakeBoxes@FileNameSetter[x] and x = Dynamic[y]; ToExpression@MakeBoxes@FileNameSetter[x] do work. $\endgroup$
    – Karsten7
    Sep 5, 2016 at 12:44
  • 1
    $\begingroup$ I think this should be tagged bugs, because MakeExpression@MakeBoxes@FileNameSetter[Dynamic[f]] and ToExpression@ToBoxes@FileNameSetter[Dynamic[f]] works in Mathematica version 9.0.1. $\endgroup$
    – Karsten7
    Sep 5, 2016 at 13:01
  • $\begingroup$ @Karsten7. thanks for checking! I agree but I wanted to ask community. $\endgroup$
    – Kuba
    Sep 5, 2016 at 13:03
  • $\begingroup$ In version 9 ToBoxes@FileNameSetter[Dynamic[f]] creates an InterpretationBox. Since version 10 a TemplateBox is created. $\endgroup$
    – Karsten7
    Sep 5, 2016 at 13:22
  • 3
    $\begingroup$ @Karsten7. The definition does exist. But it's in the stylesheet. I.e., CurrentValue[{StyleDefinitions, "FileNameSetterBoxes"}]. Which the FE understands, but the kernel does not. So this does properly roundtrip to output cells and back to input cells, but not through the more constrained MakeBoxes/MakeExpression roundtrip. $\endgroup$
    – John Fultz
    Sep 7, 2016 at 13:52

1 Answer 1

0
$\begingroup$

A support case with the identification [CASE:3706792] was created.

  • InputField

    [...] This is an issue with ToExpression. I have brought it to the attention the relevant developers and they are further investigating the issue. [...]

    Bug introduced in V10 and persisting through V11.1.1

  • FileNameSetter

    [...] the issue for FileNameSetter is different than in the other cases [...]

    Bug introduced in V10 and fixed V11.1.1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.