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

C code tries to initialize nltype with 0 in strange errorhandling / assert / module interaction #230

Closed
jrfondren opened this issue Oct 17, 2023 · 3 comments
Labels

Comments

@jrfondren
Copy link

Bug description

This is a warning with gcc, and an error with tcc. I found it naturally while using nester to test a module that used utf8.codepoint()

Code example

with modcheck.nelua:

require 'errorhandling'
local M = @record{}
local function f() assert(true) return 1 end
local x = f()
function M.f() return f() end
return M

You can observe the error with:

$ nelua -C -i 'require("modcheck")'
warning: using error handling module, it is highly experimental and incomplete!
/home/jfondren/.cache/nelua/eval_2jNUNGZEoYm.c: In function ‘nelua_require_modcheck’:
/home/jfondren/.cache/nelua/eval_2jNUNGZEoYm.c:2205:23: warning: excess elements in struct initializer
 2205 |       return (nltype){0};
      |                       ^
/home/jfondren/.cache/nelua/eval_2jNUNGZEoYm.c:2205:23: note: (near initialization for ‘(anonymous)’)

Where the larger context is

nltype nelua_require_modcheck(nlniltype modname) {
  ({
    int64_t __callret = modcheck_f();
    if(nelua_error_status) {
      return (nltype){0};
    }   
    __callret;
  });
  return NELUA_NIL;
}

Environment

x86_64 linux
Nelua 0.2.0-dev
Build number: 1588
Git date: 2023-09-16 16:20:44 -0300
Git hash: 596fcca
Semantic version: 0.2.0-dev.1588+596fcca5
Copyright (C) 2019-2022 Eduardo Bart (https://nelua.io/)

@jrfondren jrfondren added the bug label Oct 17, 2023
@edubart
Copy link
Owner

edubart commented Oct 17, 2023

Error handling module is not finished, it is full of issues. Maybe I should remove from standard library or leave in an experimental folder.

@jrfondren
Copy link
Author

I wasn't using 'errorhandling' directly, I was using nester from nelua-batteries.

edubart added a commit that referenced this issue Nov 5, 2023
@edubart
Copy link
Owner

edubart commented Nov 5, 2023

Fixed in decf713

@edubart edubart closed this as completed Nov 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants