Skip to content

Some documentation updates for Lua 5.5 - #1159

Merged
hishamhm merged 5 commits into
teal-language:mainfrom
bjornbm:main
Aug 21, 2026
Merged

Some documentation updates for Lua 5.5#1159
hishamhm merged 5 commits into
teal-language:mainfrom
bjornbm:main

Conversation

@bjornbm

@bjornbm bjornbm commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Mainly update to parts of the documentation to reflect that Lua 5.5 is a compiler target. Rather low hanging fruit I will admit.

Someone should confirm that “The options 5.4 and 5.5 are equivalent to 5.3, but also allow using the <close>
variable annotation.” (i.e., 5.5 does not introduce other changes that deserve mention. I admit I did not dig deep.)

@hishamhm

Copy link
Copy Markdown
Member

Thanks! This is much appreciated!

Perhaps a "non-difference" that might be worth mentioning in the documentation is that Teal does allow modifiying the for index variables (like Lua 5.4 and below) even when the target is Lua 5.5.

@bjornbm

bjornbm commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

Perhaps a "non-difference" that might be worth mentioning in the documentation is that Teal does allow modifiying the for index variables (like Lua 5.4 and below) even when the target is Lua 5.5.

Where would be a suitable place for this? https://github.com/teal-language/tl/blob/main/docs/src/teal_standard_library_and_lua_compatibility.md?

Also, if this is the desired behavior in Teal code, I think that when the target is 5.5 (or any target that should be compatible with 5.5) the following transformation should be used to avoid a crash (attempt to assign to const variable 'i') on 5.5:

for i = 1, 5 do
   i = i + 1
   print(i)
end

Should become:

for i = 1, 5 do local i = i
   i = i + 1
   print(i)
end

(Deserves a new issue if you agree)

@hishamhm

Copy link
Copy Markdown
Member

@bjornbm the compiler already does this :)

@bjornbm

bjornbm commented Aug 19, 2026

Copy link
Copy Markdown
Contributor Author

@hishamhm I believe I am seeing the numeric for exception reported as a one of the incidental observations in #1158:

Not addressed here

Two things I ran into while testing, both out of scope:

Numeric for has the same problem, and it is worse. Lua 5.5 also makes the
control variable of a numeric for a constant, and lua_compat.adjust_code
has no fornum case at all. So ordinary, non-macro Teal code that writes to a
numeric for variable type checks cleanly and then produces invalid Lua on 5.5:

$ lua5.5 ./tl run fornum.tl
Internal Compiler Error: Teal generator produced invalid Lua. Please report a
bug at https://github.com/teal-language/tl

fornum.tl:3: attempt to assign to const variable 'i'

This reproduces on master without any of the changes here and affects code that
has nothing to do with macros. It needs lua_compat and visitors changes, so
I left it alone — happy to open a separate issue for it.

I tried with an “pairs”-for and then the a local copy of the key is indeed assigned if the target is 5.4 or 5.5. So it seems the numeric for case was forgotten.

Comment thread docs/src/functions.md Outdated
end
```

Note, however, that named vararg tables will not be read-only when targeting Lua <5.5.

@hishamhm hishamhm Aug 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not document this line here. Instead, let's open an issue to get this fixed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note removed. We have #1160 for this since yesterday.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh sure, sorry!

@hishamhm
hishamhm merged commit 2a5cafd into teal-language:main Aug 21, 2026
8 of 9 checks passed
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

Successfully merging this pull request may close these issues.

2 participants