-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
#892 でパーサーが名前空間内の属性付き宣言をパースできるようになりましたが、インタープリターの collectNsMember では属性が無視されています。
__eval 内の宣言についての部分を見ると、右辺の式を評価した後に、宣言に付いている属性を評価して、右辺の値の attr パラメータを属性の値に書き換えていることがわかります。
aiscript/src/interpreter/index.ts
Lines 651 to 662 in 2f103d2
| if (node.attr.length > 0) { | |
| const attrs: Value['attr'] = []; | |
| for (const nAttr of node.attr) { | |
| const value = await this._eval(nAttr.value, scope, callStack); | |
| assertValue(value); | |
| attrs.push({ | |
| name: nAttr.name, | |
| value, | |
| }); | |
| } | |
| value.attr = attrs; | |
| } |
一方で、 collectNsMember の対応する部分を見ると、式を評価した後、そのままスコープに追加していることがわかります。
aiscript/src/interpreter/index.ts
Lines 251 to 271 in 2f103d2
| case 'def': { | |
| if (node.dest.type !== 'identifier') { | |
| throw new AiScriptNamespaceError('Destructuring assignment is invalid in namespace declarations.', node.loc.start); | |
| } | |
| if (node.mut) { | |
| throw new AiScriptNamespaceError('No "var" in namespace declaration: ' + node.dest.name, node.loc.start); | |
| } | |
| const value = await this._eval(node.expr, nsScope, []); | |
| assertValue(value); | |
| if ( | |
| node.expr.type === 'fn' | |
| && isFunction(value) | |
| && !value.native | |
| ) { | |
| value.name = nsScope.getNsPrefix() + node.dest.name; | |
| } | |
| this.define(nsScope, node.dest, value, node.mut); | |
| break; | |
| } |
takejohnFineArchs and syuilo
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working