- Hard limit of 127 characters for identifiers.

This commit is contained in:
Christoffer Lerno
2025-12-13 03:51:32 +01:00
parent 2a2c0f5d91
commit 466d3bc1b6
4 changed files with 14 additions and 0 deletions

View File

@@ -19,6 +19,7 @@
- Typedefs and structs with inline types supporting lengthof would not work with lengthof #2641.
- `$defined(foo())` now correctly errors if `foo()` would require a path.
- `@if($defined((char*){}.foo()))` does not error if `foo` is missing.
- Hard limit of 127 characters for identifiers.
### Stdlib changes
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.

View File

@@ -52,6 +52,7 @@ typedef uint16_t FileId;
#define MAX_GLOBAL_DECL_STACK (65536)
#define MAX_MODULE_NAME 31
#define MAX_MODULE_PATH 63
#define MAX_IDENTIFIER_LENGTH 127
#define MAX_MACRO_RECURSION_DEPTH 128
#define MEMCMP_INLINE_REGS 8
#define UINT128_MAX ((Int128) { UINT64_MAX, UINT64_MAX })

View File

@@ -349,6 +349,10 @@ EXIT:;
}
return add_error_token(lexer, "An identifier may not consist of only '_' characters.");
}
if (len > MAX_IDENTIFIER_LENGTH)
{
return add_error_token(lexer, "An identifier cannot be longer than %d characters, but this one was %u characters long.", MAX_IDENTIFIER_LENGTH, len);
}
const char* interned_string = symtab_add(lexer->lexing_start, len, hash, &type);
switch (type)
{

View File

@@ -0,0 +1,8 @@
module test;
import std;
fn int main()
{
int iodeofjoiewjfojfoiejfewjfijewfijewifjoiewjfioewjfioewjfioewjfiojewfiojewfiojeofjeiowfjioewjfioewjfioewjfijweifefefeffefefeeefef = 0;
int iodeofjoiewjfojfoiejfewjfijewfijewifjoiewjfioewjfioewjfioewjfiojewfiojewfiojeofjeiowfjioewjfioewjfioewjfijweifefefeffefefeeefef1 = 0; // #error: okfeokfe
return 0;
}