Pluto.jl: struct inside let block is always global

Created on 22 Sep 2020  路  5Comments  路  Source: fonsp/Pluto.jl

Our expression explorer uses the regular scope rules for structs. But structs are always global!

julia> let
       struct x
       end
       end

julia> x
x
bug expression explorer good first issue

All 5 comments

This has the correct behavior currently, which is that you can define struct in let block and other cells will work. and it will error when you try to re-define it. (although the error msg is a big weird: cannot assign a value to variable workspace9.x from module workspace22)

That's not the correct behavior: it shows an error message and redefining the struct is not reactive.

This test should pass:

@test testee(:(let struct a; b; c; end end), [], [], [], [
            :a => ([], [], [], [])
            ])

here https://github.com/fonsp/Pluto.jl/blob/v0.11.14/test/ExpressionExplorer.jl#L31

@fonsp #527 Make the test above pass, but wondering what exactly is the expected behaviour in the notebook? I'm not quite sure that I'm understanding it correctly.

I would say that this is a bug in Julia, but we need to mirror Julia's scoping system, which is just confusing in this case.

Thanks for the fix!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fonsp picture fonsp  路  5Comments

FelixBenning picture FelixBenning  路  3Comments

briochemc picture briochemc  路  6Comments

jarvist picture jarvist  路  6Comments

mlg556 picture mlg556  路  4Comments