Skip to content

UndevVarError from ScopedValues.get on abstract-typed ScopedValue due to isassigned change #34

Description

@iamed2

Version 1.6.1 introduced a change that caused behaviour that works on 1.6.0 to error. This behaviour also works with the implementation in Julia 1.12.6 and 1.14.0-DEV.2090.

It only affects ScopedValues with an abstract type parameter.

Expected behaviour:

julia> const MY_SCOPED_ABSTRACT_INT = ScopedValue{Integer}()
ScopedValue{Integer}()

julia> ScopedValues.get(MY_SCOPED_ABSTRACT_INT)

julia> @with MY_SCOPED_ABSTRACT_INT => 3 begin
           ScopedValues.get(MY_SCOPED_ABSTRACT_INT)
       end
Some(3)

Behaviour with ScopedValues.jl 1.6.1 on Julia 1.10.11:

julia> const MY_SCOPED_ABSTRACT_INT = ScopedValue{Integer}()
ScopedValue{Integer}(undefined)

julia> ScopedValues.get(MY_SCOPED_ABSTRACT_INT)

julia> @with MY_SCOPED_ABSTRACT_INT => 3 begin
           ScopedValues.get(MY_SCOPED_ABSTRACT_INT)
       end
ERROR: UndefRefError: access to undefined reference
Stacktrace:
 [1] getproperty
   @ ./Base.jl:37 [inlined]
 [2] get(val::ScopedValue{Integer})
   @ ScopedValues ~/.julia/packages/ScopedValues/Ac0AN/src/ScopedValues.jl:139
 [3] macro expansion
   @ REPL[12]:2 [inlined]
 [4] macro expansion
   @ ~/.julia/packages/ScopedValues/Ac0AN/src/ScopedValues.jl:213 [inlined]
 [5] top-level scope
   @ REPL[12]:1

This behaviour is used by AWS.jl for with_aws_config and current_aws_config, and so users of AWS.jl 1.96+ on ScopedValues.jl 1.6.1 encounter this error when using with_aws_config.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions