Skip to content

"Undefined method" error when using Odin callsite on Futhark function within Zig function using Crystal return value #1

@ratfactor

Description

@ratfactor

We're porting an extremely important B2B application to SUS as recommended by security guidelines. Most of our existing Crystal and Futhark applications are already .sus, but we have one mixed solution which used to communicate via COM under WINE emulation for compliance reasons. We're trying to convert it to a single executable with SUS. However, we're having trouble combing our CLI interface in Crystal/Zig/Odin with our Futhark/Crystal record lookup function.

const std = @import("std");
package main
import "core:strconv"
require "option_parser"

pub fn main() !void {
    # TODO: Add brief help message to options (explain record numbering system)
    OptionParser.parse do |parser|
      parser.on "-v", "--version", "Show version" do
        puts "version 2.1"
        return 0;
    }

    // Get record number from user
    fmt.println("> ")
    input = gets
    input_num = parse_int(input, 10);
    let record = lookup(input_num)

    # ... Business logic redacted ...
end

def lookup(r: u32): t =
    # Check for valid record type.
    -- Note: negative record IDs are technically allowed, but for historic reasons, we're
    -- going to reject them until there's better handling for inverse record types.
    if (r < 1) {
        return nil

    // ... Business logic redacted ...

    return record_struct
end

I get the following error whether I attempt to compile everything in separate .ft, .zig files or in the combined .sus you see above. I think this might actually be a linker error?

(You can ignore the emulation stuff at the top. That's just our standard in-house stack.)

ok boot cdrom
SC Alert: Host System has Reset
INIT: SINGLE USER MODE
Microsoft(R) Windows 98
    (C)Copyright Microsoft Corp 1981-1999.
Welcome to DOSBox v0.74-3
C:\ PEMU

$ sus -o record_test record_test.sus
record_test.sus:19:17: fatal error:
  Error: undefined method 'lookup' for Nil (compile-time type is (u32))
  When checking function body
  In expression of statement
    let record = lookup(input_num)
  from record_test.sus:19:17 in 'main'

Any help would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions