Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No tests for type: 'ref' #57

Closed
mathiasbynens opened this issue Aug 20, 2014 · 5 comments
Closed

No tests for type: 'ref' #57

mathiasbynens opened this issue Aug 20, 2014 · 5 comments
Labels

Comments

@mathiasbynens
Copy link
Collaborator

There are currently no tests/examples for atoms with type: 'ref' (see createRef()).

@mathiasbynens
Copy link
Collaborator Author

Also, let’s rename this to reference now that we still can. Currently it’s the only type name that is an abbreviation. :(

@mathiasbynens
Copy link
Collaborator Author

The reason there are no tests for type: 'ref' is probably because back-references are parsed as if they were simple values.

$ regjsparser '(s)\1'
{
    "type": "alternative",
    "body": [
        {
            "type": "group",
            "behavior": "normal",
            "body": [
                {
                    "type": "value",
                    "kind": "symbol",
                    "codePoint": 115,
                    "range": [
                        1,
                        2
                    ],
                    "raw": "s"
                }
            ],
            "range": [
                0,
                3
            ],
            "raw": "(s)",
            "matchIdx": 1
        },
        {
            "type": "value",
            "kind": "octal",
            "codePoint": 1,
            "range": [
                3,
                5
            ],
            "raw": "\\1"
        }
    ],
    "range": [
        0,
        5
    ],
    "raw": "(s)\\1"
}

Back-references should be preserved in the AST.

Ref. mathiasbynens/regexpu#4
Ref. bnjmnt4n/regjsgen#5

@jviereck
Copy link
Owner

This is strange and seems like a regression. Testing the ecma suite with the full RegExpJS engine worked fine last year during JSConf, so I am sure it worked somewhen^^

@mathiasbynens, I am heads down in other stuff at the moment, but I will talk about RegExp.JS at Amsterdam.JS and will make sure this is fixed before then ;)

@mathiasbynens
Copy link
Collaborator Author

Thanks for the info, @jviereck! I’ll try to look into it as well.

@bnjmnt4n
Copy link
Contributor

This seems to be related to a variable called lastMatchClosed. If you look in parseDecimalEscape, detection of references depends on lastMatchClosed, but lastMatchClosed remains at 0 throughout the script.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants