<p dir="auto">On Ubuntu 14.04:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="tkelman@nanosoldier4:~/Julia/julia-0.5$ ./julia -e 'versioninfo()' &amp;&amp; make test-reflection
Julia Version 0.5.0-dev+3719
Commit cc43988* (2016-04-23 09:07 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
    JULIA test/reflection
     * reflection           julia: /home/tkelman/Julia/julia-0.5/src/codegen.cpp:1330: uint64_t compute_obj_symsize(const llvm::object::ObjectFile*, uint64_t): Assertion `hi == 0' failed.

signal (6): Aborted
while loading /home/tkelman/Julia/julia-0.5/test/reflection.jl, in expression starting on line 40
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x2b82ba6f3b85)
__assert_fail at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
[inline] at /home/tkelman/Julia/julia-0.5/src/codegen.cpp:1330
compute_obj_symsize at /home/tkelman/Julia/julia-0.5/src/codegen.cpp:1412
_dump_function at ./reflection.jl:288
unknown function (ip: 0x2b84bfcb4366)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
test_bin_reflection at /home/tkelman/Julia/julia-0.5/test/reflection.jl:16
unknown function (ip: 0x2b84bfcc04b4)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/test/reflection.jl:22
test_code_reflections at /home/tkelman/Julia/julia-0.5/test/reflection.jl:29
unknown function (ip: 0x2b84bfc747a3)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
do_call at /home/tkelman/Julia/julia-0.5/src/interpreter.c:58
eval at /home/tkelman/Julia/julia-0.5/src/interpreter.c:181
jl_toplevel_eval_flex at /home/tkelman/Julia/julia-0.5/src/toplevel.c:535
[inline] at /home/tkelman/Julia/julia-0.5/src/toplevel.c:423
jl_toplevel_eval_flex at /home/tkelman/Julia/julia-0.5/src/toplevel.c:170
jl_toplevel_eval_flex at /home/tkelman/Julia/julia-0.5/src/toplevel.c:433
jl_parse_eval_all at /home/tkelman/Julia/julia-0.5/src/ast.c:794
jl_load at /home/tkelman/Julia/julia-0.5/src/toplevel.c:573
include at ./boot.jl:233
unknown function (ip: 0x2b82bbfef7c5)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
include_from_node1 at ./loading.jl:425
unknown function (ip: 0x2b82bc2103d5)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at ./util.jl:179
runtests at /home/tkelman/Julia/julia-0.5/test/testdefs.jl:7
[inline] at ./promotion.jl:229
#283 at ./multi.jl:774
run_work_thunk at ./multi.jl:747
unknown function (ip: 0x2b82b83f1246)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
remotecall_fetch at ./multi.jl:794
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/src/julia.h:1339
jl_apply at /home/tkelman/Julia/julia-0.5/src/builtins.c:505
unknown function (ip: 0x2b82b83db0f8)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/src/julia.h:1339
jl_apply at /home/tkelman/Julia/julia-0.5/src/builtins.c:505
[inline] at ./promotion.jl:229
remotecall_fetch at ./multi.jl:810
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/src/julia.h:1339
jl_apply at /home/tkelman/Julia/julia-0.5/src/builtins.c:505
unknown function (ip: 0x2b82b83d90f8)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/test/runtests.jl:36
#15 at ./task.jl:308
unknown function (ip: 0x2b82b83d79df)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/src/julia.h:1339
jl_apply at /home/tkelman/Julia/julia-0.5/src/task.c:249
unknown function (ip: 0xffffffffffffffff)
Allocations: 2299972 (Pool: 2298593; Big: 1379); GC: 3
Aborted
make[1]: *** [reflection] Error 134
make: *** [test-reflection] Error 2"><pre class="notranslate"><code class="notranslate">tkelman@nanosoldier4:~/Julia/julia-0.5$ ./julia -e 'versioninfo()' &amp;&amp; make test-reflection
Julia Version 0.5.0-dev+3719
Commit cc43988* (2016-04-23 09:07 UTC)
Platform Info:
  System: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Xeon(R) CPU E3-1241 v3 @ 3.50GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, haswell)
    JULIA test/reflection
     * reflection           julia: /home/tkelman/Julia/julia-0.5/src/codegen.cpp:1330: uint64_t compute_obj_symsize(const llvm::object::ObjectFile*, uint64_t): Assertion `hi == 0' failed.

signal (6): Aborted
while loading /home/tkelman/Julia/julia-0.5/test/reflection.jl, in expression starting on line 40
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x2b82ba6f3b85)
__assert_fail at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
[inline] at /home/tkelman/Julia/julia-0.5/src/codegen.cpp:1330
compute_obj_symsize at /home/tkelman/Julia/julia-0.5/src/codegen.cpp:1412
_dump_function at ./reflection.jl:288
unknown function (ip: 0x2b84bfcb4366)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
test_bin_reflection at /home/tkelman/Julia/julia-0.5/test/reflection.jl:16
unknown function (ip: 0x2b84bfcc04b4)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/test/reflection.jl:22
test_code_reflections at /home/tkelman/Julia/julia-0.5/test/reflection.jl:29
unknown function (ip: 0x2b84bfc747a3)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
do_call at /home/tkelman/Julia/julia-0.5/src/interpreter.c:58
eval at /home/tkelman/Julia/julia-0.5/src/interpreter.c:181
jl_toplevel_eval_flex at /home/tkelman/Julia/julia-0.5/src/toplevel.c:535
[inline] at /home/tkelman/Julia/julia-0.5/src/toplevel.c:423
jl_toplevel_eval_flex at /home/tkelman/Julia/julia-0.5/src/toplevel.c:170
jl_toplevel_eval_flex at /home/tkelman/Julia/julia-0.5/src/toplevel.c:433
jl_parse_eval_all at /home/tkelman/Julia/julia-0.5/src/ast.c:794
jl_load at /home/tkelman/Julia/julia-0.5/src/toplevel.c:573
include at ./boot.jl:233
unknown function (ip: 0x2b82bbfef7c5)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
include_from_node1 at ./loading.jl:425
unknown function (ip: 0x2b82bc2103d5)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at ./util.jl:179
runtests at /home/tkelman/Julia/julia-0.5/test/testdefs.jl:7
[inline] at ./promotion.jl:229
#283 at ./multi.jl:774
run_work_thunk at ./multi.jl:747
unknown function (ip: 0x2b82b83f1246)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
remotecall_fetch at ./multi.jl:794
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/src/julia.h:1339
jl_apply at /home/tkelman/Julia/julia-0.5/src/builtins.c:505
unknown function (ip: 0x2b82b83db0f8)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/src/julia.h:1339
jl_apply at /home/tkelman/Julia/julia-0.5/src/builtins.c:505
[inline] at ./promotion.jl:229
remotecall_fetch at ./multi.jl:810
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/src/julia.h:1339
jl_apply at /home/tkelman/Julia/julia-0.5/src/builtins.c:505
unknown function (ip: 0x2b82b83d90f8)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/test/runtests.jl:36
#15 at ./task.jl:308
unknown function (ip: 0x2b82b83d79df)
[inline] at /home/tkelman/Julia/julia-0.5/src/julia_internal.h:69
jl_call_method_internal at /home/tkelman/Julia/julia-0.5/src/gf.c:1430
[inline] at /home/tkelman/Julia/julia-0.5/src/julia.h:1339
jl_apply at /home/tkelman/Julia/julia-0.5/src/task.c:249
unknown function (ip: 0xffffffffffffffff)
Allocations: 2299972 (Pool: 2298593; Big: 1379); GC: 3
Aborted
make[1]: *** [reflection] Error 134
make: *** [test-reflection] Error 2
</code></pre></div>
<p dir="auto">edit: probably duplicate of <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="149897029" data-permission-text="Title is private" data-url="https://github.com/JuliaLang/julia/issues/15971" data-hovercard-type="issue" data-hovercard-url="/JuliaLang/julia/issues/15971/hovercard" href="https://github.com/JuliaLang/julia/issues/15971">#15971</a></p>
<p dir="auto">A common idiom for testing if values in a collection <code class="notranslate">C</code> are unique is</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="length(unique(C))==length(C)"><pre class="notranslate"><span class="pl-c1">length</span>(<span class="pl-c1">unique</span>(C))<span class="pl-k">==</span><span class="pl-c1">length</span>(C)</pre></div>
<p dir="auto">or variations, eg when the length <code class="notranslate">n</code> is known,</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="length(unique(C))==n"><pre class="notranslate"><span class="pl-c1">length</span>(<span class="pl-c1">unique</span>(C))<span class="pl-k">==</span>n</pre></div>
<p dir="auto">These show up in various tests, assertions, inner constructors. However, if the goal is only to test for uniqueness, not to obtain a list of unique elements, then something like</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function isunique(C)
    seen = Set{eltype(C)}()
    for x in C
        if in(x, seen)
            return false
        else
            push!(seen, x)
        end
    end
    true
end"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">isunique</span>(C)
    seen <span class="pl-k">=</span> <span class="pl-c1">Set</span><span class="pl-c1">{eltype(C)}</span>()
    <span class="pl-k">for</span> x <span class="pl-k">in</span> C
        <span class="pl-k">if</span> <span class="pl-c1">in</span>(x, seen)
            <span class="pl-k">return</span> <span class="pl-c1">false</span>
        <span class="pl-k">else</span>
            <span class="pl-c1">push!</span>(seen, x)
        <span class="pl-k">end</span>
    <span class="pl-k">end</span>
    <span class="pl-c1">true</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">is much more efficient: it can terminate early and avoids the construction of the intermediate array. Also, programmer's the intent is more clear.</p>
<p dir="auto">I am of course reluctant to suggest adding functions to <code class="notranslate">Base</code>, but it would good to have <code class="notranslate">unique</code> and <code class="notranslate">isunique</code> in the same module.</p>