ArgumentError raises an error with a standard message that includes extraMessage as a comment. This function never returns. It is an idiom to use it in Go functions as lua.ArgumentError(l, args, "message") panic("unreachable")
(l *State, argCount int, extraMessage string)
| 116 | // lua.ArgumentError(l, args, "message") |
| 117 | // panic("unreachable") |
| 118 | func ArgumentError(l *State, argCount int, extraMessage string) { |
| 119 | f, ok := Stack(l, 0) |
| 120 | if !ok { // no stack frame? |
| 121 | Errorf(l, "bad argument #%d (%s)", argCount, extraMessage) |
| 122 | return |
| 123 | } |
| 124 | d, _ := Info(l, "n", f) |
| 125 | if d.NameKind == "method" { |
| 126 | argCount-- // do not count 'self' |
| 127 | if argCount == 0 { // error is in the self argument itself? |
| 128 | Errorf(l, "calling '%s' on bad self (%s)", d.Name, extraMessage) |
| 129 | return |
| 130 | } |
| 131 | } |
| 132 | if d.Name == "" { |
| 133 | if pushGlobalFunctionName(l, f) { |
| 134 | d.Name, _ = l.ToString(-1) |
| 135 | } else { |
| 136 | d.Name = "?" |
| 137 | } |
| 138 | } |
| 139 | Errorf(l, "bad argument #%d to '%s' (%s)", argCount, d.Name, extraMessage) |
| 140 | } |
| 141 | |
| 142 | func findField(l *State, objectIndex, level int) bool { |
| 143 | if level == 0 || !l.IsTable(-1) { |
no test coverage detected