Skip to content

Array-copying algorithm fails #18

Description

@sozysozbot

The code given in the book,

吾有一列。名之曰「甲」。充「甲」以三。充「甲」以五。

吾有一列。名之曰「乙」。
凡「甲」中之「元」。充「乙」以其也。

compiles to

var 甲 = [];
甲.push(3);
甲.push(5);
var 乙 = [];
for (let 元 of 甲) {
  乙.push();
};

in both the online IDE and wenyan -c.

Contrary to what is claimed in the book (欲令其實亦二。互不相干。當如何。曰。當如是), this code does not make a copy of an array, since no element is pushed to 「乙」. Though

吾有一列。名之曰「甲」。充「甲」以三。充「甲」以五。

吾有一列。名之曰「乙」。
凡「甲」中之「元」。充「乙」以「元」也。

would fix the problem, it might be that the failure of 其 to point to 「元」 is a regression introduced somewhere within the long history of wenyan-lang.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions