Skip to content

Conversation

@jdonaldson
Copy link
Member

@jdonaldson jdonaldson commented Jan 5, 2026

Note for simn, I'm gradually chipping away at some of the leftover issues from Lua. And jotting down a few points where I hit some foot guns. I'm using AI to help generate stub files and to write tests. It's all things I wanted to do before but just couldn't find the motivation/time. I can finish off the rest of the lua-vanilla issues, but wanted to give you a chance to see the basic intent before I added a bunch of stuff.

Summary

  • EReg now conditionally compiles: stub implementation for -D lua-vanilla, real implementation otherwise
  • Stub throws NotImplementedException at runtime with a clear error message
  • Partial fix for [lua] -D lua-vanilla is ignored #12063 - removes the lrexlib-pcre2 dependency when using lua-vanilla

Background

The #error directive approach in _std override files triggers eager file scanning, causing compilation failures even when the type isn't used. This PR uses conditional compilation with a runtime stub instead.

Remaining work for #12063

Other modules still need the same treatment:

  • Sys.hx (luv)
  • sys/FileSystem.hx (luv)
  • sys/io/Process.hx (luv)
  • sys/net/*.hx (luasocket)
  • sys/ssl/Socket.hx (luasec)
  • haxe/iterators/StringIterator.hx (lua-utf8)

Test plan

  • Verify EReg compiles without lrexlib-pcre2 when using -D lua-vanilla
  • Verify EReg throws NotImplementedException at runtime in vanilla mode
  • Verify normal EReg functionality still works without -D lua-vanilla

When lua-vanilla is set, EReg now compiles to a stub that throws
NotImplementedException at runtime instead of requiring lrexlib-pcre2.

This is part of fixing HaxeFoundation#12063 - the lua-vanilla flag should produce
code without external library dependencies.
@Simn
Copy link
Member

Simn commented Jan 5, 2026

Use -D lua-vanilla=false or install lrexlib-pcre2.

This sounds like installing lrexlib-pcre2 would make it work, which I don't think is the case if we're compiling with the stub-implementation.

@jdonaldson
Copy link
Member Author

jdonaldson commented Jan 7, 2026

Yeah, this feels awkward to me too. And it's why I only showed one class and stopped short of stubbing the rest out.

The stub implementation is only included/compiled with -D lua-vanilla, which will only get included if the EReg class gets imported somewhere/somehow in a given target. If one is compiling with -D lua-vanilla, it means one is in a situation where one can't include any 3rd party libraries. This often the case when writing Lua mods, plugins, etc.

LMK if I'm missing something here, it's been a loooong time since I thought about this, and the only reason I'm taking another swing is because I had some leftover Claude code credits. :)

also, happy new year! Warm wishes.

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