1d6cce98fe
Unlike most languages with interpolated strings, Python's formatted string literals do not allow the nesting of quotes. For example, this expression is not legal Python: f"Foo {"bar"} baz" If an interpolation requires quotes, those quotes nust differ from the quotes used by the enclosing literal. We can fix the previous example by rewriting it with single quotes: f"Foo {'bar'} baz" However, this presents a problem if there are more than two levels of nesting, as Python only has two kinds of quotes (four if the outermost string uses """ or '''): in this case, the expression becomes unspellable, and must be assigned to a local that is then used in place of the original expression. So this: f"Foo {bar[f'index {baz["qux"]}']} zed" becomes this: index = "qux" f"Foo {bar[f'index {baz[index]}']}" To put it bluntly, Python code generation reqiures register allocation, but for quotes. These changes implement exactly that. These changes also include a fix for traversals that access values that are dictionaries rather than objects, and must use indexers rather than attributes. |
||
---|---|---|
.. | ||
format | ||
attribute.go | ||
binder_expression.go | ||
binder_expression_test.go | ||
block.go | ||
body.go | ||
diagnostics.go | ||
expression.go | ||
functions.go | ||
printer.go | ||
scope.go | ||
spec.md | ||
traversable.go | ||
type.go | ||
type_collection.go | ||
type_eventuals.go | ||
type_list.go | ||
type_map.go | ||
type_none.go | ||
type_object.go | ||
type_opaque.go | ||
type_output.go | ||
type_promise.go | ||
type_scope.go | ||
type_set.go | ||
type_test.go | ||
type_tuple.go | ||
type_union.go | ||
utilities.go | ||
visitor.go |