Skip to content

Conversation

mlechu
Copy link
Member

@mlechu mlechu commented Oct 10, 2025

hasmethod returns false when the world argument specified is greater than the global latest world. We often use typemax(UInt) as a token for "latest world" though; JuliaLowering uses this to check if there's a provenance-preserving macro of a given name before falling back to the Expr macro (a bit of a hack, but losing provenance with every @nospecialize would be unfortunate for JETLS, and we want to call our own version of @ccall).

@Keno suggested throwing an error for too-large worlds other than typemax, which is implemented here.

@mlechu mlechu requested a review from Keno October 10, 2025 16:20
end

function hasmethod(f, t, kwnames::Tuple{Vararg{Symbol}}; world::UInt=get_world_counter())
function hasmethod(f, t, kwnames::Tuple{Vararg{Symbol}}; world::UInt=typemax(UInt))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think get_world_counter is still the preferred default, typemax is a bit of a hack.

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typemax(UInt) as a token for "latest world" though

This has been deprecated for several releases now (it was a legacy hack) . I would rather not bring back this hack, since it is not correctly reflecting what this actually means, and is a nonsense special case.

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_world_counter is not accessible everywhere (sometimes it is defined to be typemax, indicating that the world is unbounded dynamically), so this will lead to potentially more confusing errors and more buggy code. I really don't think we should do attempt to make a special case to make hasmethod error.

@mlechu
Copy link
Member Author

mlechu commented Oct 10, 2025

Fair enough, although we should still update the docstring and either remove the "code reflection cannot be used from generated functions" check or add it to the non-keyword-argument case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants