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

Disallow Foo.bar and Foo as variable names #2987

Merged
merged 3 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-bananas-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@quri/squiggle-lang": patch
---

Disallow capitalized variable names that we allowed by accident in 0.9.0
2 changes: 2 additions & 0 deletions packages/squiggle-lang/__tests__/ast/parse_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ describe("Peggy parse", () => {
testParse("x = 1", "(Program (LetStatement :x (Block 1)))");
testParse("x", "(Program :x)");
testParse("x = 1; x", "(Program (LetStatement :x (Block 1)) :x)");
testEvalError("X = 1");
testEvalError("Foo.bar = 1");
});

describe("functions", () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/squiggle-lang/src/ast/peggyParser.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ statement
/ defunStatement

letStatement
= exported:("export" __nl)? variable:variable _ assignmentOp _nl value:zeroOMoreArgumentsBlockOrExpression
= exported:("export" __nl)? variable:dollarIdentifier _ assignmentOp _nl value:zeroOMoreArgumentsBlockOrExpression
{ return h.nodeLetStatement(variable, value, Boolean(exported), location()); }

defunStatement
= exported:("export" __nl)? variable:variable '(' _nl args:functionParameters _nl ')' _ assignmentOp _nl body:innerBlockOrExpression
= exported:("export" __nl)? variable:dollarIdentifier '(' _nl args:functionParameters _nl ')' _ assignmentOp _nl body:innerBlockOrExpression
{
const value = h.nodeLambda(args, body, location(), variable);
return h.nodeDefunStatement(variable, value, Boolean(exported), location());
Expand Down