Struct field change bug - can't understand why?


I’m trying to understand why the compiler produces an error when you try to change a field of a mutable struct after a “”" comment “”".

I tried to reduce this to the minimum possible code that reproduces this error, :

mutable struct teststruct




testinstance = teststruct(0.5, "hello")

testinstance.a = 0.1 # works fine

"""a comment string"""

testinstance.a = 0.75 # generates error message

The error I get is:

ERROR: LoadError: MethodError: no method matching Base.Docs.Binding(::teststruct, ::Symbol)
Closest candidates are:
  Base.Docs.Binding(!Matched::Module, ::Symbol) at docs\bindings.jl:12
 [1] include_from_node1(::String) at .\loading.jl:576
 [2] include(::String) at .\sysimg.jl:14
 [3] process_options(::Base.JLOptions) at .\client.jl:305
 [4] _start() at .\client.jl:371
while loading C:\Projects\11_Louis\osContrib\heisenbug\test.jl, in expression starting on line 522

Thanks for any help on this.


Because that is not a comment.

See also """ vs #= =# comment


This is a doc-string, which tries to attach the doc to something but fails and thus errors. Use # for comments.


thanks for clarifying, missed that in the manual and assumed Python-like behavior, my mistake :slight_smile: