HaxeFoundation / HaxeFoundation/haxe
[lua] EReg.replace fails with lua 5.1.5 (windows)
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
The code:
``` haxe
class Main {
public static function main() {
var e = ~/a/gi;
var s1 = "aaabbbccc";
var s2 = e.replace(s1, "d");
trace(s1, s2);
}
}
```
Returns the next error:
```
lua: bin\main.lua:526: bad argument #2 to 'gsub' (string expected, got userdata)
stack traceback:
[C]: in function 'gsub'
bin\main.lua:526: in function 'replace'
bin\main.lua:538: in function 'main'
bin\main.lua:1213: in main chunk
[C]: ?
```
This is the lua code:
``` lua
EReg.prototype = _hx_anon(
'replace', function(self,s,by)
by = lua.lib.lrexlib.Rex.gsub(by,"\\$(\\d)","%%1");
by = lua.lib.lrexlib.Rex.gsub(by,"\\${2}","$");
do return lua.lib.lrexlib.Rex.gsub(s,self.r,by,(function()
local _hx_1
if (self.global) then
_hx_1 = nil; else _hx_1 = 1; end
return _hx_1
end )()) end
end
)
```
Using the latest Haxe build from http://builds.haxe.org `(git build development @ 8926bc5)` on Windows.
Using the latest lua release from [LuaForWindows](https://github.com/rjpcomputing/luaforwindows/releases)
Contributor guide
Assessment
This issue has not been assessed yet.