This would be expected to throw an error for any b not equal to Bcode(1). You are seeing a StackOverflowError in place of the true error, which should be something like
ERROR: IndexError("Dictionary does not contain index: Bcode(50)")
Stacktrace:
[1] getindex(dict::Dictionary{Bcode, String}, i::Bcode)
@ Dictionaries ~/.julia/packages/Dictionaries/8bcEH/src/AbstractDictionary.jl:46
It’s not clear to me what you are trying to achieve with what appears to be an unusual convert method. I think you would need to explain this reason, in addition to the odd behaviour.
When Dictionary does not find Bcode(2) as a key in the dictionary, it wants to print an error message:
ERROR: Dictionaries.IndexError("Dictionary does not contain index: ***Bcode(2)***")
But the ***Bcode(2)*** in this hypothetical error message is the output of stringifying Bcode(2), which prints this error. So an infinite recursion loop is called which isn’t infinite, because the call stack is exhausted, and StackOverflowError triggered.
To avoid this, perhaps getkey should be used instead of indexing into dictionary. getkey has a default value. The following: