<p dir="auto">In the following example, julia fails to elide the view of the array if the view thinks the underlying array is a matrix rather than a vector.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function matrix_view(a)
    @views a[:,1]
    0
end

a = randn(3)
A = randn(3,1)
@btime matrix_view($a)
@btime matrix_view($A)

julia&gt; @btime matrix_view($a)
  48.592 ns (2 allocations: 96 bytes)

julia&gt; @btime matrix_view($A)
  1.541 ns (0 allocations: 0 bytes)"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">matrix_view</span>(a)
    <span class="pl-c1">@views</span> a[:,<span class="pl-c1">1</span>]
    <span class="pl-c1">0</span>
<span class="pl-k">end</span>

a <span class="pl-k">=</span> <span class="pl-c1">randn</span>(<span class="pl-c1">3</span>)
A <span class="pl-k">=</span> <span class="pl-c1">randn</span>(<span class="pl-c1">3</span>,<span class="pl-c1">1</span>)
<span class="pl-c1">@btime</span> <span class="pl-c1">matrix_view</span>(<span class="pl-k">$</span>a)
<span class="pl-c1">@btime</span> <span class="pl-c1">matrix_view</span>(<span class="pl-k">$</span>A)

julia<span class="pl-k">&gt;</span> <span class="pl-c1">@btime</span> <span class="pl-c1">matrix_view</span>(<span class="pl-k">$</span>a)
  <span class="pl-c1">48.592</span> ns (<span class="pl-c1">2</span> allocations<span class="pl-k">:</span> <span class="pl-c1">96</span> bytes)

julia<span class="pl-k">&gt;</span> <span class="pl-c1">@btime</span> <span class="pl-c1">matrix_view</span>(<span class="pl-k">$</span>A)
  <span class="pl-c1">1.541</span> ns (<span class="pl-c1">0</span> allocations<span class="pl-k">:</span> <span class="pl-c1">0</span> bytes)</pre></div>
<p dir="auto">The problem might be related to the fact that the view thinks the parent is a matrix based on the appearance of the indexing expression, which can not be guaranteed.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="view(a, :, 1)
3-element view(::Matrix{Float64}, :, 1) with eltype Float64:"><pre class="notranslate"><span class="pl-c1">view</span>(a, :, <span class="pl-c1">1</span>)
<span class="pl-c1">3</span><span class="pl-k">-</span>element <span class="pl-c1">view</span>(<span class="pl-k">::</span><span class="pl-c1">Matrix{Float64}</span>, :, <span class="pl-c1">1</span>) with eltype Float64<span class="pl-k">:</span></pre></div>
<p dir="auto">Taking out the new <code class="notranslate">immutable</code> out for a spin it behaves initially as expected.</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
immutable Foo
       bar::Int
       baz::String
end

qux = Foo(1, &quot;hi&quot;)

julia&gt; qux.bar = 2
ERROR: type Foo is immutable"><pre class="notranslate">immutable Foo
       bar<span class="pl-k">::</span><span class="pl-c1">Int</span>
       baz<span class="pl-k">::</span><span class="pl-c1">String</span>
<span class="pl-k">end</span>

qux <span class="pl-k">=</span> <span class="pl-c1">Foo</span>(<span class="pl-c1">1</span>, <span class="pl-s"><span class="pl-pds">"</span>hi<span class="pl-pds">"</span></span>)

julia<span class="pl-k">&gt;</span> qux<span class="pl-k">.</span>bar <span class="pl-k">=</span> <span class="pl-c1">2</span>
ERROR<span class="pl-k">:</span> type Foo is immutable</pre></div>
<p dir="auto">Yeah. But when I use arrays I get a different unexpected behavior ....</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="immutable Timeseries
       timestamp::Vector{CalendarTime}
       values::Array
end

bing = Timeseries([now()], [1])

bing.values[1] = 2

julia&gt; bing
Timeseries([2013-03-14],[2])"><pre class="notranslate">immutable Timeseries
       timestamp<span class="pl-k">::</span><span class="pl-c1">Vector{CalendarTime}</span>
       values<span class="pl-k">::</span><span class="pl-c1">Array</span>
<span class="pl-k">end</span>

bing <span class="pl-k">=</span> <span class="pl-c1">Timeseries</span>([<span class="pl-c1">now</span>()], [<span class="pl-c1">1</span>])

bing<span class="pl-k">.</span>values[<span class="pl-c1">1</span>] <span class="pl-k">=</span> <span class="pl-c1">2</span>

julia<span class="pl-k">&gt;</span> bing
<span class="pl-c1">Timeseries</span>([<span class="pl-c1">2013</span><span class="pl-k">-</span><span class="pl-c1">03</span><span class="pl-k">-</span><span class="pl-c1">14</span>],[<span class="pl-c1">2</span>])</pre></div>