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

function to print StaticString does not compile #65

Open
sadish-d opened this issue Dec 3, 2024 · 2 comments
Open

function to print StaticString does not compile #65

sadish-d opened this issue Dec 3, 2024 · 2 comments

Comments

@sadish-d
Copy link

sadish-d commented Dec 3, 2024

The function f1 below compiles but f2 does not.

function f1(n_args::Int64, ::Ptr{Ptr{UInt8}})
    message = (n_args == 0 ? c"____0" : c"other")::StaticTools.StaticString{6}
    StaticTools.print(message)
    return zero(Int64)
end

function f2(n_args::Int64, ::Ptr{Ptr{UInt8}})
    message = (n_args == 0 ? c"____0" : n_args == 1 : c"____1" : c"other")::StaticTools.StaticString{6}
    StaticTools.print(message)
    return zero(Int64)
end

StaticCompiler.compile_executable(f1, (Int64, Ptr{Ptr{UInt8}}), "./")
StaticCompiler.compile_executable(f2, (Int64, Ptr{Ptr{UInt8}}), "./")

versioninfo:

Julia Version 1.10.3
Commit 0b4590a5507 (2024-04-30 10:59 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 
@brenhinkeller
Copy link
Owner

brenhinkeller commented Dec 3, 2024 via email

@sadish-d
Copy link
Author

sadish-d commented Dec 3, 2024

I'm not sure that's the issue. f3 and f4 don't compile either:

function f3(n_args::Int64, ::Ptr{Ptr{UInt8}})
    message =
        if n_args == 0
            c"____0"
        elseif n_args == 1
            c"____1"
        else
            c"other"
        end::StaticTools.StaticString{6}
    StaticTools.print(message)
    return zero(Int64)
end

function f4(n_args::Int64, ::Ptr{Ptr{UInt8}})
    message = ifelse(n_args == 0, c"____0", ifelse(n_args == 1, c"____1", c"other"))::StaticTools.StaticString{6}
    StaticTools.print(message)
    return zero(Int64)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants