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

Escaped variable names #104

Open
sryffel opened this issue Mar 1, 2021 · 3 comments
Open

Escaped variable names #104

sryffel opened this issue Mar 1, 2021 · 3 comments
Labels

Comments

@sryffel
Copy link

sryffel commented Mar 1, 2021

Describe the bug
Escaped variables not handled correctly.

To Reproduce
The following code evaluates to "b":

var variables = new Dictionary<string, object>()
{
    { @"[a]", "a" },
    { @"\a\", "b" }
};
var expression = new Expression(@"[\[a\]]");
Console.WriteLine(expression.Evaluate(variables));

Expected behavior
The expected result would be "a".

Platform:

  • OS: .NET Core 3.1 on Windows
@bijington
Copy link
Owner

Thanks for the bug report. I can quite easily reproduce the behaviour that you are seeing here.

Out of interest what is your need to include the escaped [ ] characters in the variable names?

@bijington bijington added the bug label Mar 1, 2021
@sryffel
Copy link
Author

sryffel commented Mar 1, 2021

Thank you for your quick response.

This is just something I discovered "by accident" ;)

@bijington
Copy link
Owner

Haha the best type of testing/bug discovery :).

I mainly asked in case you were wanting to embed an expression inside of another expression which is entirely possible:

var variables = new Dictionary<string, object>()
{
    { @"a", new Expression("[b]") },
    { @"b", "c" }
};
var expression = new Expression(@"[a]");
Console.WriteLine(expression.Evaluate(variables));

Which should evaluate to c.

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

2 participants