Skip to content

Pointer to the cst gets lost once we start navigating through the tree. #1128

@Janther

Description

@Janther

Took me a while to reproduce it consistently but this is the behaviour I'm experiencing in v0.18.2

import { Parser } from '@nomicfoundation/slang/parser';
import { SourceUnit } from '@nomicfoundation/slang/ast';
import { NonterminalKind } from '@nomicfoundation/slang/cst';

const source = `
pragma solidity ^0.8.0;
`;
const parser = Parser.create('0.8.28');
const parseOutput = parser.parse(NonterminalKind.SourceUnit, source);
parseOutput.isValid(); // true

const ast = new SourceUnit(parseOutput.tree.asNonterminalNode()!);

console.log(ast.cst.kind); // SourceUnit
console.log(ast.members.cst.kind); // SourceUnitMembers
console.log(ast.cst.kind); // Resource error: Not a valid "NonterminalNode" resource.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions