5756 Commits

Author SHA1 Message Date
Roberto Ierusalimschy
cfce6f4b20 Warning in loslib.c (signed-unsigned comparison) v5.5-beta 2025-06-27 14:47:11 -03:00
Roberto Ierusalimschy
1da89da62f Manual updated to version 5.5 2025-06-27 14:46:41 -03:00
Roberto Ierusalimschy
f6c627af20 Cast added to 'add_history'
MacOS defines 'add_history' with a "wrong" type (it returns 'int'
instead of 'void').
2025-06-26 11:45:42 -03:00
Roberto Ierusalimschy
270a58c062 Application name for 'readline' is "lua", not "Lua" =list 2025-06-23 14:36:32 -03:00
Roberto Ierusalimschy
30531c291b Refactoring in the use of 'readline' by 'lua.c'
More common code for 'readline' loaded statically or dynamically (or
not loaded).
2025-06-23 14:00:21 -03:00
Roberto Ierusalimschy
07b009c371 No need to limit variable declarations to 250
Only local variables, which use registers, need this low limit.
2025-06-18 16:45:55 -03:00
Roberto Ierusalimschy
f711567448 Check string indices when loading binary chunk
Lua is not religious about that, but it tries to avoid crashes when
loading binary chunks.
2025-06-17 11:40:49 -03:00
Roberto Ierusalimschy
9386e49a31 New metatable in an all-weak table can fool the GC
All-weak tables are not being revisited after being visited during
propagation; if it gets a new metatable after that, the new metatable
may not be marked.
2025-06-16 16:29:32 -03:00
Roberto Ierusalimschy
8cd7ae7da0 Simpler code for 'traversetable'
Check the mode in a separate function (getmode), instead of using
comma expressions inside the 'if' condition.
2025-06-16 15:50:12 -03:00
Roberto Ierusalimschy
0cecf1ab6d Dump uses varints also for integer constants
Unlike sizes, these constants can be negative, so it encodes those
integers into unsigned integers in a way that keeps small numbers
small.
2025-06-13 14:14:50 -03:00
Roberto Ierusalimschy
e657a48ea5 The main thread cannot be closed
No thread started with pcall (instead of resume) can be closed,
because coroutine.close would not respect the expected number of
results from the protected call.
2025-06-13 14:08:38 -03:00
Roberto Ierusalimschy
fd897027f1 A coroutine can close itself
A call to close itself will close all its to-be-closed variables and
return to the resume that (re)started the coroutine.
2025-06-12 11:15:09 -03:00
Roberto Ierusalimschy
d05fe48bfd Loading a binary chunk should not break assertions
Although the execution of a bad binary chunk can crash the interpreter,
simply loading it should be safe.
2025-06-04 12:55:43 -03:00
Roberto Ierusalimschy
519c57d597 Removed uneeded check in parser
In a constructor, each field generates at least one opcode, and the
number of opcodes is limited by INT_MAX. Therefore, the counters for
number of fields cannot exceed this limit. (The current limit for
items in the hash part of a table has a limit smaller than INT_MAX.
However, as long as there are no overflows, the logic for table
resizing will handle that limit.)
2025-06-04 09:54:31 -03:00
Roberto Ierusalimschy
c15543b9af Bug: check for constructor overflow in [exp] fields
The check for constructor overflow was considering only fields with
explicit names, ignoring fields with syntax '[exp]=exp'.
2025-05-20 17:50:56 -03:00
Roberto Ierusalimschy
be05c44481 New way to control preambular declaration
Validity of the preambular global declaration in controled together
with all declarations, when checking variable names.
2025-05-20 17:36:05 -03:00
Roberto Ierusalimschy
6d53701c7a Proper error message when jumping into 'global *'
A goto cannot jump into the scope of any variable declaration,
including 'global *'. To report the error, it needs a "name" for
the scope it is entering.
2025-05-18 12:03:54 -03:00
Roberto Ierusalimschy
abbae57c78 Variable attributes can prefix name list
In this format, the attribute applies to all names in the list;
e.g. "global<const> print, require, math".
2025-05-18 11:43:43 -03:00
Roberto Ierusalimschy
f2c1531e6c Detail
Reports errors with "?:?:" (instead of "?👎") when there is no debug
information.
2025-05-16 15:20:32 -03:00
Roberto Ierusalimschy
ded2ad2d86 Slightly faster way to check for "global" 2025-05-16 14:51:07 -03:00
Roberto Ierusalimschy
3fb7a77731 Internalized string "break" kept by the parser
The parser uses "break" as fake label to compile "break" as "goto
break". To avoid producing this string at each use, it keeps it
available in its state.
2025-05-15 12:43:37 -03:00
Roberto Ierusalimschy
fded0b4a84 Remove compat code in parser when not needed 2025-05-13 11:50:43 -03:00
Roberto Ierusalimschy
3b9dd52be0 Collective declaration for globals ('global *') 2025-05-13 11:43:10 -03:00
Roberto Ierusalimschy
7dc6aae290 Correct line in error message for constant function 2025-05-12 11:42:45 -03:00
Roberto Ierusalimschy
5b1ab8efdc 'expdesc' doesn't depend on 'actvar' for var. info.
In preparation for 'global *', the structure 'expdesc' does not point
to 'actvar.arr' for information about global variables.
2025-05-11 11:51:58 -03:00
Roberto Ierusalimschy
7ade155762 Janitorial work on casts 2025-05-08 15:18:57 -03:00
Roberto Ierusalimschy
d827e96f33 Using 'l_uint32' for unicode codepoints in scanner
'l_uint32' is enough for unicode codepoints (versus unsigned long),
and the utf-8 library already uses that type.
2025-05-08 12:49:39 -03:00
Roberto Ierusalimschy
3f0ea90aa8 New syntax 'global function' 2025-05-08 11:08:03 -03:00
Roberto Ierusalimschy
4365a45d68 Checks for read-only globals 2025-05-06 15:54:05 -03:00
Roberto Ierusalimschy
be81209063 First implementation of global declarations 2025-05-05 16:24:59 -03:00
Roberto Ierusalimschy
e055905914 New macro 'pushvfstring'
Helps to ensure that 'luaO_pushvfstring' is being called correctly,
with an error check after closing the vararg list with 'va_end'.
2025-04-23 11:55:04 -03:00
Roberto Ierusalimschy
9b014d4bcd Details (typos in comments) 2025-04-23 11:36:09 -03:00
Roberto Ierusalimschy
50fd8d03c3 Function 'luaK_semerror' made vararg
All calls to 'luaK_semerror' were using 'luaO_pushfstring' to create
the error messages.
2025-04-17 14:58:55 -03:00
Roberto Ierusalimschy
3dbb1a4b89 In gen. GC, some gray objects stay in gray lists
In generational collection, objects marked as touched1 stay in gray
lists between collections. This commit fixes a bug introduced in
commit 808976bb59.
2025-04-15 17:00:30 -03:00
Roberto Ierusalimschy
3dd8ea54da Order change in 'pushfuncname'
'pushglobalfuncname' can be quite slow (as it traverses all globals and
all loaded modules), so try first to get a name from the code.
2025-04-03 15:31:22 -03:00
Roberto Ierusalimschy
620f49a7aa Tiny refactoring in io.flush 2025-04-03 12:56:52 -03:00
Roberto Ierusalimschy
3f4f28010a io.write returns number of written bytes on error 2025-04-03 11:32:49 -03:00
Roberto Ierusalimschy
93e347b519 Corrections of stack addresses back to strict mode
It can be a little slower, but only for quite large stacks and moreover
stack reallocation is not a common operation.  With no strong contrary
reason, it is better to follow the standard.
2025-04-01 10:41:25 -03:00
Roberto Ierusalimschy
f4123b2fc2 Growth factor of 1.5 for stack and lexical buffer 2025-03-31 13:44:41 -03:00
Roberto Ierusalimschy
37a1b72706 Small optimization in 'project' from math.random
When computing the Mersenne number, instead of spreading 1's a fixed
number of times (with shifts of 1, 2, 4, 8, 16, and 32), spread only
until the number becomes a Mersenne number.
2025-03-27 15:22:40 -03:00
Roberto Ierusalimschy
ef5d171cc8 New macro 'l_numbits' 2025-03-27 12:38:29 -03:00
Roberto Ierusalimschy
b0f3df16a4 Addition in math.random can overflow
To avoid complains from some tools, the addition when computing
math.random(n,m), which is computed as n + random(0, m - n), should
use unsigned integers.
2025-03-25 11:43:03 -03:00
Roberto Ierusalimschy
cad5a4fdbb Details
Small changes in test library:
- execute mode added to 'all.lua';
- more information about subtypes (tags) when printing a stack.
2025-03-24 15:23:55 -03:00
Roberto Ierusalimschy
fdbb4c2341 Detail in the manual 2025-03-17 16:05:47 -03:00
Roberto Ierusalimschy
921832be8d New function 'resetCI'
New function 'resetCI' resets the CallInfo list of a thread, ensuring
a proper state when creating a new thread, closing a thread, or
closing a state, so that we can run code after that. (When closing a
thread, we need to run its __close metamethods; when closing a
state, we need to run its __close metamethods and its finalizers.)
2025-03-17 14:32:08 -03:00
Roberto Ierusalimschy
205f9aa67b New function 'printallstack' in test library 2025-03-17 14:30:43 -03:00
Roberto Ierusalimschy
94d38560c3 Wrong error message when using "_ENV" fields
The string "_ENV" is erroneously identified as a variable _ENV,
so that results from a field is classified as a global.
2025-03-14 15:16:09 -03:00
Roberto Ierusalimschy
c2dc6e8e94 Missing GC barrier in 'luaV_finishset' 2025-03-14 12:37:19 -03:00
Roberto Ierusalimschy
22974326ca Use after free in 'luaV_finishset'
If a metatable is a weak table, its __newindex field could be collected
by an emergency collection while being used in 'luaV_finishset'. (This
bug has similarities with bug 5.3.2-1, fixed in commit a272fa66.)
2025-03-13 15:30:52 -03:00
Roberto Ierusalimschy
c931d86e98 'luaD_seterrorobj' should not raise errors
This function can be called unprotected, so it should not raise any
kind of errors. (It could raise a memory-allocation error when creating
a message).
2025-03-12 15:51:16 -03:00