Skip to content

Single quoted string parsing behavior #69

@kczx3

Description

@kczx3

Single quoted strings that begin with two forward slashes and also contain an escaped single quote are parsed incorrectly. I assume that this is an upstream issue with https://github.com/tree-sitter/tree-sitter-php.

Sample code:

<?php

$thing = 'Hello';
$out['stuff']['one'] = dummyfunc($thing, '//test[duh=\'uh oh\']/thing');
$out['stuff']['two'] = dummyfunc($thing, '//');

    if ($thing == 'Hello') {
        print 'Hello World';
        
        if ($thing == 'Hello') {
            null;
        }
        else {
            null;
        }
    }

function dummyfunc(string $str1, string $str2): string {
    return $str1 . ' ' . $str2;
}

The above renders as this in Zed:

Image

The same does not occur if I switch to using double quotes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions