Corner components lost when copying a layer via script

I’ve been struggling with this for days: Glyphs (I’m using v2.6.6) appears to lose corner components when I copy a path—or even an entire layer, in most situations. I haven’t tried this in Glyphs 3, with copying layer.shapes, but I find it frustrating and unexpected that layer.paths excludes corner components. That said, I’ve read other forum posts about that and I can accept it. But I absolutely cannot lose corners when copying a whole layer.

After hours of testing, I discovered two scenarios in which corners are reliably lost (A) or retained (B).

By the way, in the examples below, I get the same results with layer.copy() and copy.copy(layer) .

Scenario 1: Copying a Layer

I can copy a layer into another using the = equal sign. For example: thisLayer = copyOfOtherLayer . But corner components are lost (not copied) when I’m assigning the layer to a variable, like targetLayer in example A. Everything else in the layer copies without a problem, so it doesn’t seem to be a variable assignment issue.

# A: Copies layer contents without corner components
targetLayer = {{some_layer}}.background
targetLayer = copy.copy( {{some_other_layer}} )

Setting the copied layer onto the target layer, and getting that layer before the = seems keep the corner components.

# B: Copies layer contents with corner components
targetLayer = {{some_layer}}
targetLayer.background = copy.copy( {{some_other_layer}} )

Scenario 2: Removing Overlap/Decompose Corners

Ideally, I’d like to copy a layer into a temporary GSLayer, make some changes to it like decomposing corners and removing overlap, and then use that temporary layer’s paths somewhere else—as shown in example A, below.

I can copy a layer into a variable like temporaryLayer, but when I try to decompose the corners, the corners disappear. By the way, .decomposeCorners() has no effect in this situation, which I presume is a bug. removeOverlap() decomposes corners, but, again, the corners get lost if this is run on temporaryLayer .

# A: Filters/functions for decomposing corner components fail
temporaryLayer = {{some_layer}}.copy()
temporaryLayer.decomposeCorners() # this has no effect
temporaryLayer.removeOverlap() # successfully removes overlap but loses corner components

If, instead of copying a layer into a temporaryLayer variable, I copy it into an actual glyph’s layer (for example, the a glyphs’s master layer), the corner components survive .removeOverlap() . In example B, below, imagine glyph.layers[0] is that a glyphs’s first master layer.

# B: Filters/functions for decomposing corner components succeed
glyph.layers[0] = temporaryLayer # put the temp (orphan) layer into a real glyph layer or background
glyph.layers[0].removeOverlap() # successfully removes overlap

Can you please improve the reliability of corner components in the API?

I should be able to copy a layer into another without losing them sometimes. I should also be able to copy a layer into a temporary variable (making it an “orphan” GSLayer) and run filters and functions like .removeOverlap() without any issue.