Facepunch / garrysmod-issues

Garry's Mod issue tracker
144 stars 56 forks source link

Error now behaves like ErrorNoHalt #2113

Open Lexicality opened 9 years ago

Lexicality commented 9 years ago
] lua_run Error("test") print("what the fuck")
> Error("test") print("what the fuck")...
testwhat the fuck
] lua_run error("ffs") print("why")
> error("ffs") print("why")...

[ERROR] lua_run:1: ffs
  1. error - [C]:-1
   2. unknown - lua_run:1
Acecool commented 9 years ago

If I recall, command-line is executed one command after the other where-as in a file with a pointer is where Error would prevent the pointer from continuing down the file.

If this is a new issue from today then I can test on my dev-server to confirm ( last update was a few days to a week ago )....

willox commented 9 years ago

If I recall, command-line is executed one command after the other where-as in a file with a pointer is where Error would prevent the pointer from continuing down the file.

The entire string is ran as a single block of code.

Lexicality commented 9 years ago

If I recall, command-line is executed one command after the other where-as in a file with a pointer is where Error would prevent the pointer from continuing down the file.

This is not the case. You can see by the fact that "why" is not printed to console, and also the fact that I know about this to start off with. (Unless you regularly type random functions into console to check that they work?)

Acecool commented 9 years ago

Then I stand corrected in terms of the behavior!

It appears the same behavior is on my end ( dev version, last update a few days to a week ago ). ErrorNoHalt and Error allow the next command to output while error prevents this; both using lua_run... I use lua_run, rarely, when testing certain functionality without triggering auto-refresh...

If ran as a single block of code, then this is undesired behavior.

Edit: I just tested it in a file... Same results. Error failed to prevent the pointer from continuing whether called alone in a file or in a function called from the file.

Lexicality commented 9 years ago

If you're still not convinced that it's not an exciting variation caused by the console, try this

function test(foo)
    if not foo then
        Error("No foo provided!")
    end
    foo.bar()
end
test()

output:

] lua_openscript errortest.lua
Running script errortest.lua...
No foo provided!
[ERROR] lua/errortest.lua:5: attempt to index local 'foo' (a nil value)
  1. test - lua/errortest.lua:5
   2. unknown - lua/errortest.lua:7
willox commented 9 years ago

I think this has been beyond confirmed :kiss: Same result in both branches.

Kefta commented 6 years ago

3 years later and still no way to throw a halting error without the stack trace

robotboy655 commented 5 years ago

It wasn't changed since June 2014 (as far as our commit history goes), but they indeed both run exactly the same code.

@Kefta why would you want to?

Kefta commented 5 years ago

Because I'm making a Lua preprocessor that alters line count and function bounds so I need to print out my own stack trace.