Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: print line number of ignored statements #739

Merged
merged 5 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions bindings/javascript/src/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ test("error format contains newlines", async t => {
await zencode_exec(`a`);
} catch (e) {
const lines = e.logs.split('\n');

t.true(lines.includes('[W] Zencode text too short to parse'));
t.true(lines.includes('[W] Zencode is missing version check, please add: rule check version N.N.N'));
t.true(lines.includes('[!] Execution aborted with errors.'));
t.true(lines.includes('[!] Zencode parser error'));
}
})

Expand Down
2 changes: 1 addition & 1 deletion bindings/python3/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_zencode_failure():
Then print the data
"""
res = zencode_exec(contract)
assert("ERROR" in res.logs)
assert("fatal error" in res.logs)

# def test_lua_call_hello_world():
# lua_res = zenroom_exec(
Expand Down
7 changes: 4 additions & 3 deletions src/lua/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
-- zen_load_extensions(L) usually after zen_init()

-- -- remap fatal and error
function fatal(msg)
function fatal(x)
ZEN.debug()
msg = msg or 'fatal error'
error(msg, 2)
local msg <const> = x.msg or 'fatal error'
error('Zencode line '..x.linenum..': '..msg, 2)
end

_G['REQUIRED'] = {}
Expand Down Expand Up @@ -87,6 +87,7 @@ MAXITER = tonumber(STR_MAXITER)
-- ZENCODE starts here

-- declare HEAP globals in the main co-routine
AST = {} -- Abstract Syntax Tree filled by ZEN:parser
IN = {} -- Given processing, import global DATA from json
TMP = {} -- temporary buffer used by Given
ACK = {} -- When processing, destination for push*
Expand Down
1 change: 1 addition & 0 deletions src/lua/statemachine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ function machine.create(options)
fsm.options = options
fsm.current = options.initial or 'none'
fsm.events = {}
fsm.line = 0

for _, event in ipairs(options.events or {}) do
local name = event.name
Expand Down
Loading
Loading