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

'with' or quick binding operator bug #136

Open
D0ctorWh0 opened this issue Jan 31, 2021 · 1 comment
Open

'with' or quick binding operator bug #136

D0ctorWh0 opened this issue Jan 31, 2021 · 1 comment
Labels

Comments

@D0ctorWh0
Copy link

D0ctorWh0 commented Jan 31, 2021

Hi!

I came across your project and it looks very interesting. I played a bit with it and get an error when trying to use 'with' and quick binding operator.

When I write this EC# code

Point p = new Point(0, 0);
var point2 = new Point(2,2);

with (p)
{
    .X = 0;
    .Y = 1;
}

it generates valid C# code

Point p = new Point(0, 0);
var point2 = new Point(2, 2);
{
var tmp_10 = p;
tmp_10.X = 0;
tmp_10.Y = 1;
}

But when I try this EC# code

Point p = new Point(0, 0);
new Point(2,2)::point2;

with (p)
{
    .X = 0;
    .Y = 1;
}

it generates invalid C# code

Point p = new Point(0, 0);
var point2 = new Point(2, 2);
point2;
{
var tmp_10 = p;
tmp_10.X = 0;
tmp_10.Y = 1;
}

P.S. Why keeping braces from 'with' is C# code?

I tried to use only quick binding operator and it gives some error. Am I using it wrong?

@D0ctorWh0 D0ctorWh0 changed the title 'with' bug 'with' or quick binding operator bug Jan 31, 2021
@qwertie qwertie added the bug label Feb 1, 2021
@qwertie
Copy link
Owner

qwertie commented Feb 1, 2021

I've reproduced the bug - including the variant where new P()::p; on a line by itself produces uncompilable code - and I should point out that with is not compatible with value types like Point, as the temporary variable is not ref. LeMP is not aware of the type system and cannot detect value types. (Potentially ref could be added on the temporary variable to fix the problem, but in other cases this could cause a compiler error). There's a note of caution in the documentation but I could have made it clearer...

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