Open voigt opened 1 week ago
Hi @voigt I will look at this.
Ah, yeah this is a bit confusing for sure. What is happening is that items
is a built-in function on maps in Risor, like the items
built-in on Python dicts.
Built-ins get priority over map attributes in an access like this.
The updated code to handle this case would use ["attr"] based access. This session in the REPL shows more:
Risor
>>> issues := {"items": [1,2,3]}
>>> issues
{"items": [1, 2, 3]}
>>> issues.items
builtin(map.items)
>>> issues.items()
[["items", [1, 2, 3]]]
>>> issues['items']
[1, 2, 3]
>>>
I was a bit worried when I added map item access using .attr
because of the potential for this confusion.
Improving the to-string formatting to show something more useful in the case you reported initially would be one way to make this a bit better.
Hey,
lately I noticed an inconsistent while unmarshalling a json struct:
What I did
items
objectWhich produced following output
Expected output
risor version
I think this is a very odd behaviour, and probably not intended, as it prevents me from accessing any items of
data.items
.