<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="julia&gt; begin
           module A
           1
           end
       end
ERROR: syntax: module expression not at top level"><pre class="notranslate">julia<span class="pl-k">&gt;</span> <span class="pl-k">begin</span>
           <span class="pl-k">module</span> A
           <span class="pl-c1">1</span>
           <span class="pl-k">end</span>
       <span class="pl-k">end</span>
ERROR<span class="pl-k">:</span> syntax<span class="pl-k">:</span> <span class="pl-k">module</span> expression not at top level</pre></div>
<p dir="auto">Theoretically this should work, because module A is indeed in global scope? Would be helpful to get working for macros which operate on large blocks of global code</p>
<p dir="auto">Looks like a bug in <code class="notranslate">eval</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type &quot;help()&quot; to list help topics
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.2.0-514.r3d43
 _/ |\__'_|_|_|\__'_|  |  Commit 3d43df9032 2013-03-16 06:59:07
|__/                   |

julia&gt; @eval begin
           type T 
               x 
           end
           T(sum([1,2]))
       end
T(3)

julia&gt; @eval begin
           type T2 
               x 
           end
           s = 0
           for i in [1,2]
               s += i
           end
           T2(s)
       end
ERROR: error compiling anonymous: unsupported or misplaced expression composite_type in function anonymous"><pre class="notranslate"><code class="notranslate">   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" to list help topics
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.2.0-514.r3d43
 _/ |\__'_|_|_|\__'_|  |  Commit 3d43df9032 2013-03-16 06:59:07
|__/                   |

julia&gt; @eval begin
           type T 
               x 
           end
           T(sum([1,2]))
       end
T(3)

julia&gt; @eval begin
           type T2 
               x 
           end
           s = 0
           for i in [1,2]
               s += i
           end
           T2(s)
       end
ERROR: error compiling anonymous: unsupported or misplaced expression composite_type in function anonymous
</code></pre></div>