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

prevent With clause name shadowing #359

Open
agentm opened this issue Nov 21, 2022 · 3 comments
Open

prevent With clause name shadowing #359

agentm opened this issue Nov 21, 2022 · 3 comments

Comments

@agentm
Copy link
Owner

agentm commented Nov 21, 2022

Name shadowing can be quite a footgun. Example:

TutorialD (master/main): x:=with (x as true) x
("with type",Relation (attributesFromList []) (RelationTupleSet {asList = []}))
("with type",Relation (attributesFromList []) (RelationTupleSet {asList = []}))
TutorialD (master/main): :showexpr x
ERR: RelVarAlreadyDefinedError "x"

The original expression should almost certainly be rejected, but the relational expression validation is sound, so we would need to check that the new relvarname "x" is not mentioned in the with clause names.

I am toying with the idea of preventing name shadowing of relvars or other with clause macro names (even macros shadowing macros). It does seem that name shadowing can be sometimes useful when moving subexpressions around, but the risk and cost of mistakes here is very high.

Any objection?

@YuMingLiao
Copy link
Contributor

YuMingLiao commented Nov 22, 2022

TutorialD (master/main): x:=with (x as true) x
TutorialD (master/main): :showexpr x
┌┐
││
├┤
└┘

It seems fine on my machine. I would like to give opinions but I found myself not understand the issue here at all. What's the risk?

@agentm
Copy link
Owner Author

agentm commented Nov 22, 2022

Indeed, it's just on a future branch, but what's the point of supporting that expression? It makes substitution much more difficult and optimizations have to track shadowed names recursively.

@YuMingLiao
Copy link
Contributor

I see. I can't think of a useful example either.

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

No branches or pull requests

2 participants