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

missing notes on compile error #3726

Closed
lun-4 opened this issue Nov 19, 2019 · 1 comment
Closed

missing notes on compile error #3726

lun-4 opened this issue Nov 19, 2019 · 1 comment
Labels
stage1 The process of building from source via WebAssembly and the C backend.
Milestone

Comments

@lun-4
Copy link
Contributor

lun-4 commented Nov 19, 2019

This code

pub const XML_ElementDeclHandler = ?extern fn ([*c]const u8, [*c][*c]const u8) void;
pub extern fn XML_SetElementDeclHandler(eldecl: XML_ElementDeclHandler) void;

extern fn someOtherFunction(a: [*]const u8, b: [*][*]const u8) void {
    return;
}

pub fn main() void {
    XML_SetElementDeclHandler(someOtherFunction);
}

gives the following:

test36.zig:9:31: error: expected type '?extern fn([*c]const u8, [*c][*c]const u8) void', found 'extern fn([*]const u8, [*][*]const u8) void'
    XML_SetElementDeclHandler(someOtherFunction);
                              ^

A big help could be adding notes to help the writer that they should use optionals e.g ?[*]const u8. For example, the last note on this snippet

From IRC:

[17:51] < andrewrk> lunamn, yes, in fact I'm pretty sure it's a TODO in the compiler already, just needs a bit of glue code to wire that up
@daurnimator daurnimator added the stage1 The process of building from source via WebAssembly and the C backend. label Nov 19, 2019
@andrewrk andrewrk added this to the 0.7.0 milestone Nov 27, 2019
@andrewrk andrewrk modified the milestones: 0.7.0, 0.8.0 Oct 17, 2020
@andrewrk andrewrk modified the milestones: 0.8.0, 0.9.0 Nov 6, 2020
@andrewrk andrewrk modified the milestones: 0.9.0, 0.10.0 May 19, 2021
@Vexu
Copy link
Member

Vexu commented Dec 28, 2022

Now gives:

a.zig:9:31: error: expected type '*const fn([*c]const u8, [*c][*c]const u8) callconv(.C) void', found '*const fn([*]const u8, [*][*]const u8) callconv(.C) void'
    XML_SetElementDeclHandler(someOtherFunction);
                              ^~~~~~~~~~~~~~~~~
a.zig:9:31: note: pointer type child 'fn([*]const u8, [*][*]const u8) callconv(.C) void' cannot cast into pointer type child 'fn([*c]const u8, [*c][*c]const u8) callconv(.C) void'
a.zig:9:31: note: parameter 0 '[*]const u8' cannot cast into '[*c]const u8'
a.zig:9:31: note: '[*c]const u8' could have null values which are illegal in type '[*]const u8'
referenced by:
    callMain: zig-out/lib/zig/std/start.zig:604:17
    initEventLoopAndCallMain: zig-out/lib/zig/std/start.zig:548:34
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

Plenty of tests can be found by grepping for any of those errors.

@Vexu Vexu closed this as completed Dec 28, 2022
@andrewrk andrewrk modified the milestones: 0.12.0, 0.11.0 Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage1 The process of building from source via WebAssembly and the C backend.
Projects
None yet
Development

No branches or pull requests

4 participants