Skip to content

Use of @assert in Core.Compiler can result in unintended errors #50536

@maleadt

Description

@maleadt

For example

# If they didn't pass typemax(UInt) but passed something more subtly
# incorrect, fail out loudly.
@assert world <= get_world_counter()

Triggering this shows

world = Base.get_world_counter() = 0x0000000000007b86
Internal error: encountered unexpected error in runtime:
MethodError(f=Base.string, args=(Expr(:call, :<=, :world, Expr(:call, :get_world_counter)),), world=0x00000000000015aa)
jl_method_error_bare at /home/tim/Julia/src/julia/src/gf.c:2204
jl_method_error at /home/tim/Julia/src/julia/src/gf.c:2222
jl_lookup_generic_ at /home/tim/Julia/src/julia/src/gf.c:3053 [inlined]
ijl_apply_generic at /home/tim/Julia/src/julia/src/gf.c:3068
macro expansion at ./error.jl:231 [inlined]
#NativeInterpreter#287 at ./compiler/types.jl:360
NativeInterpreter at ./compiler/types.jl:349 [inlined]
typeinf_ext_toplevel at ./compiler/typeinfer.jl:1078

It's actually the rendering by @assert that fails, but the point remains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    error handlingHandling of exceptions by Julia or the user

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions