Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add <: to add-dots #35085

Merged
merged 15 commits into from
May 6, 2020
Merged

add <: to add-dots #35085

merged 15 commits into from
May 6, 2020

Conversation

ssikdar1
Copy link
Contributor

@ssikdar1 ssikdar1 commented Mar 12, 2020

Fixes #34839 .
Add <: to add-dots.

Testing

Not sure if there's somewhere to add a test?
But testing in the REPL:

julia> [Int, Float64, String, Bool] .<: Union{Int, String}
4-element BitArray{1}:
 1
 0
 1
 0

src/julia-parser.scm Outdated Show resolved Hide resolved
@stevengj stevengj added the parser Language parsing and surface syntax label Mar 12, 2020
@stevengj
Copy link
Member

Probably add a test to test/broadcast.jl or test/parse.jl?

@mbauman
Copy link
Member

mbauman commented Mar 12, 2020

What should @. do? It currently leaves <: alone.

julia> @macroexpand @. [Int, Number] <: Real
:([Int, Number] <: Real)

@ararslan ararslan added needs news A NEWS entry is required for this change needs tests Unit tests are required for this change labels Mar 12, 2020
@stevengj
Copy link
Member

@mbauman, the PR will need a case for head === :(<:) here.

@ssikdar1
Copy link
Contributor Author

ssikdar1 commented Mar 13, 2020

@stevengj

  • Tried to add a test case in 2e2c6bf.
  • And tried to add a conditional case for __dot__ in c364df6. ( not sure if this is correct ).

@ssikdar1
Copy link
Contributor Author

Tried to add .>: in 2fca8fa

There's seems to be an exception that being printed to stderr somewhere that doesn't actually affect the outcome of executing .>:.

For example:

$ cat foo.jl 
@show [Int, Float64, String, Bool] .>: Union{Int, String}

Redirecting stderr to /dev/null everything is okay.

$ ./julia foo.jl 2>/dev/null 
[Int, Float64, String, Bool] .>: Union{Int, String} = Bool[0, 0, 0, 0]

However without it:

$ ./julia foo.jl
Internal error: encountered unexpected error in runtime:
MethodError(f=typeof(Core.Compiler.length)(), args=(nothing,), world=0x0000000000000f46)
jl_method_error_bare at /Users/ssikdar1/julia/src/gf.c:1722
jl_method_error at /Users/ssikdar1/julia/src/gf.c:1740
jl_lookup_generic_ at /Users/ssikdar1/julia/src/gf.c:2311
jl_apply_generic at /Users/ssikdar1/julia/src/gf.c:2332
abstract_call_known at ./compiler/abstractinterpretation.jl:854
abstract_call at ./compiler/abstractinterpretation.jl:905
return_type_tfunc at ./compiler/tfuncs.jl:1491
abstract_call_known at ./compiler/abstractinterpretation.jl:830
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1238
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:484
abstract_call_method at ./compiler/abstractinterpretation.jl:414
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:111
abstract_call_known at ./compiler/abstractinterpretation.jl:883
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1223
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:484
abstract_call_method at ./compiler/abstractinterpretation.jl:414
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:111
abstract_call_known at ./compiler/abstractinterpretation.jl:883
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1238
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_ext at ./compiler/typeinfer.jl:570
typeinf_ext at ./compiler/typeinfer.jl:601
jfptr_typeinf_ext_22237 at /Users/ssikdar1/julia/usr/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/ssikdar1/julia/src/./julia.h:1696 [inlined]
jl_type_infer at /Users/ssikdar1/julia/src/gf.c:215
jl_generate_fptr at /Users/ssikdar1/julia/src/jitlayers.cpp:232
jl_compile_method_internal at /Users/ssikdar1/julia/src/gf.c:1902
_jl_invoke at /Users/ssikdar1/julia/src/gf.c:2162 [inlined]
jl_apply_generic at /Users/ssikdar1/julia/src/gf.c:2336
jl_apply at /Users/ssikdar1/julia/src/./julia.h:1696 [inlined]
do_call at /Users/ssikdar1/julia/src/interpreter.c:369
eval_stmt_value at /Users/ssikdar1/julia/src/interpreter.c:409 [inlined]
eval_body at /Users/ssikdar1/julia/src/interpreter.c:807
jl_interpret_toplevel_thunk at /Users/ssikdar1/julia/src/interpreter.c:915
top-level scope at show.jl:613
jl_toplevel_eval_flex at /Users/ssikdar1/julia/src/toplevel.c:813
jl_parse_eval_all at /Users/ssikdar1/julia/src/ast.c:907
jl_load_rewrite at /Users/ssikdar1/julia/src/toplevel.c:871 [inlined]
jl_load at /Users/ssikdar1/julia/src/toplevel.c:876
include at ./Base.jl:380
include at ./Base.jl:368
exec_options at ./client.jl:288
_start at ./client.jl:490
jfptr__start_54862 at /Users/ssikdar1/julia/usr/lib/julia/sys.dylib (unknown line)
true_main at /Users/ssikdar1/julia/./julia (unknown line)
main at /Users/ssikdar1/julia/./julia (unknown line)
Internal error: encountered unexpected error in runtime:
MethodError(f=typeof(Core.Compiler.length)(), args=(nothing,), world=0x0000000000000f46)
jl_method_error_bare at /Users/ssikdar1/julia/src/gf.c:1722
jl_method_error at /Users/ssikdar1/julia/src/gf.c:1740
jl_lookup_generic_ at /Users/ssikdar1/julia/src/gf.c:2311
jl_apply_generic at /Users/ssikdar1/julia/src/gf.c:2332
abstract_call_known at ./compiler/abstractinterpretation.jl:854
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_apply at ./compiler/abstractinterpretation.jl:614
abstract_call_known at ./compiler/abstractinterpretation.jl:683
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1238
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:484
abstract_call_method at ./compiler/abstractinterpretation.jl:414
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:111
abstract_call_known at ./compiler/abstractinterpretation.jl:883
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_apply at ./compiler/abstractinterpretation.jl:614
abstract_call_known at ./compiler/abstractinterpretation.jl:683
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1238
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:484
abstract_call_method at ./compiler/abstractinterpretation.jl:414
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:111
abstract_call_known at ./compiler/abstractinterpretation.jl:883
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1223
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:484
abstract_call_method at ./compiler/abstractinterpretation.jl:414
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:111
abstract_call_known at ./compiler/abstractinterpretation.jl:883
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1238
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:484
invoke_tfunc at ./compiler/tfuncs.jl:1170
builtin_tfunction at ./compiler/tfuncs.jl:1360
builtin_tfunction at ./compiler/tfuncs.jl:1309 [inlined]
abstract_call_known at ./compiler/abstractinterpretation.jl:699
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1238
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_edge at ./compiler/typeinfer.jl:484
abstract_call_method at ./compiler/abstractinterpretation.jl:414
abstract_call_gf_by_type at ./compiler/abstractinterpretation.jl:111
abstract_call_known at ./compiler/abstractinterpretation.jl:883
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1238
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_ext at ./compiler/typeinfer.jl:570
typeinf_ext at ./compiler/typeinfer.jl:601
jfptr_typeinf_ext_22237 at /Users/ssikdar1/julia/usr/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/ssikdar1/julia/src/./julia.h:1696 [inlined]
jl_type_infer at /Users/ssikdar1/julia/src/gf.c:215
jl_generate_fptr at /Users/ssikdar1/julia/src/jitlayers.cpp:232
jl_compile_method_internal at /Users/ssikdar1/julia/src/gf.c:1902
_jl_invoke at /Users/ssikdar1/julia/src/gf.c:2162 [inlined]
jl_apply_generic at /Users/ssikdar1/julia/src/gf.c:2336
copy at ./broadcast.jl:840
materialize at ./broadcast.jl:820
jl_apply at /Users/ssikdar1/julia/src/./julia.h:1696 [inlined]
do_call at /Users/ssikdar1/julia/src/interpreter.c:369
eval_stmt_value at /Users/ssikdar1/julia/src/interpreter.c:409 [inlined]
eval_body at /Users/ssikdar1/julia/src/interpreter.c:807
jl_interpret_toplevel_thunk at /Users/ssikdar1/julia/src/interpreter.c:915
top-level scope at show.jl:613
jl_toplevel_eval_flex at /Users/ssikdar1/julia/src/toplevel.c:813
jl_parse_eval_all at /Users/ssikdar1/julia/src/ast.c:907
jl_load_rewrite at /Users/ssikdar1/julia/src/toplevel.c:871 [inlined]
jl_load at /Users/ssikdar1/julia/src/toplevel.c:876
include at ./Base.jl:380
include at ./Base.jl:368
exec_options at ./client.jl:288
_start at ./client.jl:490
jfptr__start_54862 at /Users/ssikdar1/julia/usr/lib/julia/sys.dylib (unknown line)
true_main at /Users/ssikdar1/julia/./julia (unknown line)
main at /Users/ssikdar1/julia/./julia (unknown line)
Internal error: encountered unexpected error in runtime:
MethodError(f=typeof(Core.Compiler.length)(), args=(nothing,), world=0x0000000000000f46)
jl_method_error_bare at /Users/ssikdar1/julia/src/gf.c:1722
jl_method_error at /Users/ssikdar1/julia/src/gf.c:1740
jl_lookup_generic_ at /Users/ssikdar1/julia/src/gf.c:2311
jl_apply_generic at /Users/ssikdar1/julia/src/gf.c:2332
abstract_call_known at ./compiler/abstractinterpretation.jl:854
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_apply at ./compiler/abstractinterpretation.jl:614
abstract_call_known at ./compiler/abstractinterpretation.jl:683
abstract_call at ./compiler/abstractinterpretation.jl:905
abstract_call at ./compiler/abstractinterpretation.jl:890
abstract_eval at ./compiler/abstractinterpretation.jl:984
typeinf_local at ./compiler/abstractinterpretation.jl:1238
typeinf_nocycle at ./compiler/abstractinterpretation.jl:1294
typeinf at ./compiler/typeinfer.jl:12
typeinf_ext at ./compiler/typeinfer.jl:570
typeinf_ext at ./compiler/typeinfer.jl:601
jfptr_typeinf_ext_22237 at /Users/ssikdar1/julia/usr/lib/julia/sys.dylib (unknown line)
jl_apply at /Users/ssikdar1/julia/src/./julia.h:1696 [inlined]
jl_type_infer at /Users/ssikdar1/julia/src/gf.c:215
jl_generate_fptr at /Users/ssikdar1/julia/src/jitlayers.cpp:232
jl_compile_method_internal at /Users/ssikdar1/julia/src/gf.c:1902
_jl_invoke at /Users/ssikdar1/julia/src/gf.c:2162 [inlined]
jl_apply_generic at /Users/ssikdar1/julia/src/gf.c:2336
jl_apply at /Users/ssikdar1/julia/src/./julia.h:1696 [inlined]
do_apply at /Users/ssikdar1/julia/src/builtins.c:643
_broadcast_getindex at ./broadcast.jl:619
getindex at ./broadcast.jl:564
macro expansion at ./broadcast.jl:910 [inlined]
macro expansion at ./simdloop.jl:77 [inlined]
copyto! at ./broadcast.jl:909
_jl_invoke at /Users/ssikdar1/julia/src/gf.c:2169 [inlined]
jl_gf_invoke_by_method at /Users/ssikdar1/julia/src/gf.c:2420 [inlined]
jl_gf_invoke at /Users/ssikdar1/julia/src/gf.c:2385
jl_f_invoke at /Users/ssikdar1/julia/src/builtins.c:1007
copyto! at ./broadcast.jl:920
copyto! at ./broadcast.jl:864
copy at ./broadcast.jl:840
materialize at ./broadcast.jl:820
jl_apply at /Users/ssikdar1/julia/src/./julia.h:1696 [inlined]
do_call at /Users/ssikdar1/julia/src/interpreter.c:369
eval_stmt_value at /Users/ssikdar1/julia/src/interpreter.c:409 [inlined]
eval_body at /Users/ssikdar1/julia/src/interpreter.c:807
jl_interpret_toplevel_thunk at /Users/ssikdar1/julia/src/interpreter.c:915
top-level scope at show.jl:613
jl_toplevel_eval_flex at /Users/ssikdar1/julia/src/toplevel.c:813
jl_parse_eval_all at /Users/ssikdar1/julia/src/ast.c:907
jl_load_rewrite at /Users/ssikdar1/julia/src/toplevel.c:871 [inlined]
jl_load at /Users/ssikdar1/julia/src/toplevel.c:876
include at ./Base.jl:380
include at ./Base.jl:368
exec_options at ./client.jl:288
_start at ./client.jl:490
jfptr__start_54862 at /Users/ssikdar1/julia/usr/lib/julia/sys.dylib (unknown line)
true_main at /Users/ssikdar1/julia/./julia (unknown line)
main at /Users/ssikdar1/julia/./julia (unknown line)
[Int, Float64, String, Bool] .>: Union{Int, String} = Bool[0, 0, 0, 0]

@JeffBezanson
Copy link
Member

A non-fatal internal error is happening and getting printed; execution continues. I'll look into it.

@ssikdar1
Copy link
Contributor Author

ssikdar1 commented Mar 19, 2020

With @JeffBezanson #35136 , .>: looks to be working!

$ cat foo.jl 
@show [Int, Float64, String, Bool] .>: Union{Int, String}

$ ./julia foo.jl 
[Int, Float64, String, Bool] .>: Union{Int, String} = Bool[0, 0, 0, 0]

base/broadcast.jl Outdated Show resolved Hide resolved
base/broadcast.jl Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
@stevengj stevengj added triage This should be discussed on a triage call and removed needs news A NEWS entry is required for this change needs tests Unit tests are required for this change labels May 6, 2020
NEWS.md Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
NEWS.md Outdated Show resolved Hide resolved
test/broadcast.jl Outdated Show resolved Hide resolved
@JeffBezanson JeffBezanson merged commit 99dbd2d into JuliaLang:master May 6, 2020
@ssikdar1 ssikdar1 deleted the dots branch May 6, 2020 15:16
@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label May 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vectorized subtype comparison
5 participants