# Wrong autogenerated package from notebook containing #key and Part as subscript

Bug introduced in 10.0.0 and persisting through 10.1.0 or later

Mathematica v10.1.0, under Windows 8.1 x64

Mathematica v10.0.2, under Windows

1) Define a function in an initialization cell:

lowerBound =
\!$$\*SubscriptBox[\(#Range$$, $$\(\[LeftDoubleBracket]$$$$1$$$$\ \[RightDoubleBracket]$$\)]\) &;


2) Test the function (OK)

lowerBound@<|"Range" -> {1, 2}|>


1

3) Save this notebook (as test.nb) and choose to autogenerate the package with initialization cells.

4) Load the auto-generated package.

Get["test.m", Path -> {NotebookDirectory[]}]


5) Show the definition (ah!)

?? lowerBound


lowerBound=Range[[1]]&

6) Test the function (Error!)

lowerBound@<|"Range" -> {1, 2}|>


During evaluation of In[5]:= Part::partd: Part specification Range[[1]] is longer than depth of object. >>

Range[[1]]

## Update: Wolfram Research Opinion

Hello,

Thank you for your email.

I have filed a bug report with the development team. Thank you very much for giving us feedback and hopefully this issue would be improved in future release. For the time being, you can use "#Range[[1]]&" for the function definition (note that [[1]] is not a subscript of "#Range").

I hope this helps and please let me know if you have any other questions.

Sincerely,

Wolfram Technical Support

• I can confirm the problem in 10.0.2 under Windows. – Mr.Wizard Apr 15 '15 at 18:14
• Thanks for the update from WRI. I added the bugs tag and standard header. – Mr.Wizard Apr 21 '15 at 22:34