Skip to content

Builtin Begin not adding variable in context and End leaves traces of variables defined by Begin[] #1655

@rocky

Description

@rocky

Description

Begin is not adding context, and End might not be removing variables added.

How to Reproduce and Output Given

In[1]:= ??f
Out[1]= Global`f

In[2]:= Begin["MyContext`"]
Out[2]= "MyContext`"

In[3]:= f[x_] := x^2

In[4]:= ??f
Out[4]= Global`f  (* Wrong. Should be MyContext` *)       
        f[x_] = x^2

In[5]:= End[]
Out[5]= "MyContext`"

In[6]:= ??f
Out[6]= Global`f (* Wrong. Should have been removed *)
        
        f[MyContext`x_] = MyContext`x^2

Additional context

Noticed while trying to understand why certain Mathematica packages are failing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions