Add a test case about assigning to builtin constants
Pallene already forbids this but I think it would be a good idea to add a test case for it.
@@ -405,7 +405,7 @@ describe("Assignment statement", function()
]], "LHS of assignment is not a mutable variable")
end)
- it("catches assignment to builtin (with correct type)", function ()
+ it("catches assignment to builtin function (with correct type)", function ()
assert_error([[
function m.f(x: string)
end
@@ -416,7 +416,7 @@ describe("Assignment statement", function()
]], "LHS of assignment is not a mutable variable")
end)
- it("catches assignment to builtin (with wrong type)", function ()
+ it("catches assignment to builtin function (with wrong type)", function ()
assert_error([[
function m.f(x: integer)
end
@@ -427,6 +427,14 @@ describe("Assignment statement", function()
]], "LHS of assignment is not a mutable variable")
end)
+ it("catches assignment to builtin constant", function()
+ assert_error([[
+ function m.g()
+ math.pi = 3.0
+ end
+ ]], "LHS of assignment is not a mutable variable")
+ end)
+
it("catches too few values in RHS", function()
assert_error([[
function m.f()
