JuliaDiff / JuliaDiff/ChainRulesCore.jl

Better error message when using @scalar_rule on functors/closures

Open
#203 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

rule definition helper
Dominant language
Julia
Stars
267
Forks
66
PR merge metrics
No merged PRs in 30d

Description

struct MyStruct
    a
end

(m::MyStruct)(t) = m.a

@scalar_rule (m::Struct)(t) one(m.a)

Results in UndefVarError: m not defined.

As per the docs, this should not work. @oxinabox pointed out on slack that this should lead to a more meaningful error message.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the @scalar_rule implementation and reproduce the MyStruct functor example from the issue. Trace why it reports UndefVarError: m not defined, then make the unsupported functor or closure form produce a more meaningful error consistent with the documentation.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.