Skip to content
This repository was archived by the owner on Feb 20, 2024. It is now read-only.

Trying to compile skew-api to C++ gives an error #14

Open
mingodad opened this issue May 19, 2016 · 2 comments
Open

Trying to compile skew-api to C++ gives an error #14

mingodad opened this issue May 19, 2016 · 2 comments

Comments

@mingodad
Copy link

Hello !
Trying to compile skew-api to C++ gives this error:

node skewc.js src/backend/sourcemap.sk src/backend/javascript.sk src/backend/emitter.sk src/backend/cplusplus.sk src/backend/csharp.sk src/backend/lisptree.sk src/core/operators.sk src/core/node.sk src/core/symbol.sk src/core/content.sk src/core/support.sk src/frontend/parser.sk src/frontend/version.sk src/frontend/lexer.sk src/frontend/token.sk src/frontend/pratt.sk src/frontend/source.sk src/frontend/log.sk src/frontend/range.sk src/middle/lambdaconversion.sk src/middle/type.sk src/middle/folding.sk src/middle/librarycpp.sk src/middle/unicode.sk src/middle/renaming.sk src/middle/resolving.sk src/middle/globalizing.sk src/middle/typecache.sk src/middle/callgraph.sk src/middle/motion.sk src/middle/compiler.sk src/middle/scope.sk src/middle/ide.sk src/middle/interfaceremoval.sk src/middle/shaking.sk src/middle/librarycs.sk src/middle/inlining.sk src/middle/controlflow.sk src/middle/merging.sk src/middle/libraryjs.sk src/middle/library.sk src/lib/timestamp.sk src/driver/jsapi.sk --inline-functions --verbose --message-limit=0 --output-file=out/skew-api.cpp --release  --target=cpp
src/driver/jsapi.sk:342:25: error: All control paths for "<lambda>" must return a value of type "dynamic"
    var handleMessage = (message dynamic) dynamic => {
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated
@mingodad
Copy link
Author

Adding a return to this declaration silence the error, how to deal with situations like this ?

    var handleMessage = (message dynamic) dynamic => {
      switch message.type {
        case "compile" { return handleCompile(message) }
        case "tooltip-query" { return handleTooltipQuery(message) }
        case "definition-query" { return handleDefinitionQuery(message) }
        case "symbols-query" { return handleSymbolsQuery(message) }
        case "rename-query" { return handleRenameQuery(message) }
        case "completion-query" { return handleCompletionQuery(message) }
        case "signature-query" { return handleSignatureQuery(message) }
        default { throw dynamic.Error.new("Unexpected message type '\(message.type)'") }
      }
      return null //////////////////silence the error
    }

@evanw
Copy link
Owner

evanw commented May 20, 2016

This looks like a bug in my control flow analysis. I can fix that bug and in the meantime you can just move the throw statement outside the switch statement to get it to compile.

However, the file jsapi.sk binds the Skew API to the JavaScript runtime and so is very unlikely to work when cross-compiled to C++. It's sometimes desirable to write Skew bindings to JavaScript in Skew so that the Skew compiler can include that code in the JavaScript minification and other optimizations that the compiler does. This is not the case for the C++ target. Skew's type system cannot express most of the C++ type system, so Skew bindings to C++ are best written in C++. See https://github.com/evanw/sky/blob/master/osx/osx.mm for an example.

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

No branches or pull requests

2 participants