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

Error messages when starting carp repl #71

Closed
porky11 opened this issue Oct 17, 2017 · 15 comments
Closed

Error messages when starting carp repl #71

porky11 opened this issue Oct 17, 2017 · 15 comments

Comments

@porky11
Copy link

porky11 commented Oct 17, 2017

Can't understand type when registering '+'
Can't understand type when registering '-'
Can't understand type when registering '*'
Can't understand type when registering '/'
Can't understand type when registering '<'
Can't understand type when registering '>'
Can't understand type when registering '='
Can't understand type when registering 'mod'
Can't understand type when registering 'seed'
Can't understand type when registering 'random'
Can't understand type when registering 'random-between'
Can't understand type when registering 'str'
Can't understand type when registering 'from-string'
Can't understand type when registering 'mask'
Can't understand type when registering 'inc'
Can't understand type when registering 'dec'
Can't understand type when registering 'copy'
[TYPE ERROR] Trying to refer to an undefined symbol 'for' at line 9, column 9.
Can't understand type when registering '='
Can't understand type when registering 'copy'
Can't understand type when registering 'count'
Can't understand type when registering 'duplicate'
Can't understand type when registering 'cstr'
Can't understand type when registering 'str'
Can't understand type when registering 'chars'
[PARSE ERROR] "(source)" (line 9, column 10):
unexpected "'"
expecting "&", "@", "(", "[", digit, "-", "\"", "\\", letter or ")"

The REPL itself works. But I only get useful output for strings:
string _0 = strdup("Test");
Else I get nothing or error messages.

@eriksvedang
Copy link
Collaborator

Hmm, seems like there's a problem with the quote... What OS are you on? Also, I've pushed some changes to the code now, so make sure you build a version from the latest source, maybe it has been fixed.

@ephetic
Copy link

ephetic commented Oct 17, 2017

I don't get those errors starting the repl, but I do get:

Welcome to Carp 0.2.0
This is free software with ABSOLUTELY NO WARRANTY.
Evaluate (help) for more information.
鲮 (+ 1 1)
[TYPE ERROR] Trying to refer to an undefined symbol '+' at line 1, column 1 in 'REPL'.
鲮

Additionally, trying to run the tests yields:

$ ./run_carp_tests.sh
Welcome to Carp 0.2.0
This is free software with ABSOLUTELY NO WARRANTY.
Evaluate (help) for more information.
[TYPE ERROR] Can't unify

  even? : Int
  line 122, column 63 in './examples/basics.carp'

with

  expected argument to 'Array.filter' : &Int
  line 122, column 56 in './examples/basics.carp'


[TYPE ERROR] Trying to refer to an undefined symbol 'map-filter-reduce-stuff' at line 187, column 7 in './examples/basics.carp'.
Compiled to './out/lib.so'
/bin/sh: ./out/a.out: No such file or directory
[RUNTIME ERROR] callCommand: ./out/a.out (exit 127): failed
鲮

I am on OSX 10.11.6

I just cloned recently:
commit 3b08f90
Date: Tue Oct 17 17:08:53 2017 +0200

@eriksvedang
Copy link
Collaborator

eriksvedang commented Oct 17, 2017

OK, yes the first error is because you didn't qualify '+', by default you have to write Int.+ to get the int version of plus. A way to solve that is to run (use Int) first. Entering expressions in the REPL will only print the resulting C code though, so to be able to run the code you need to define a main function.

For example:

(defn main [] (IO.println &(Int.str (Int.+ 2 3))))

The second error should be fixed in the latest commit, just do an update again.

@eriksvedang
Copy link
Collaborator

Alternatively:

(use Int)
(use IO)
(defn main [] (println (refstr (+ 2 3))))

@ephetic
Copy link

ephetic commented Oct 17, 2017

Just pulled and the tests get a lot further. Perhaps this is a standard lib I just don't have on my work computer:

[@"Hi!" @"Hi!" @"Hi!" @"Hi!" @"Hi!"]
[@"hej" @"san" @"!"]
[1 2 3]
[4 5 6]
[7 8 9]
[10 9 8 7 6 5 4 3 2 1 0]
[1.000000 1.100000 1.200000 1.300000 1.400000 1.500000 1.600000 1.700000 1.800000 1.900000 2.000000]
[1 3 5 7 9]
Welcome to Carp 0.2.0
This is free software with ABSOLUTELY NO WARRANTY.
Evaluate (help) for more information.
./out/main.c:1:10: fatal error: 'SDL2/SDL_image.h' file not found
#include <SDL2/SDL_image.h>
         ^
1 error generated.
[RUNTIME ERROR] callCommand: clang ./out/main.c -o ./out/a.out -D_THREAD_SAFE -I/usr/local/include/SDL2 -fPIC -lSDL2_image -lSDL2 -L/usr/local/lib -lm -I.//core/  -g  (exit 1): failed```

@eriksvedang
Copy link
Collaborator

eriksvedang commented Oct 17, 2017

Yes, it needs SDL2 and SDL_image to work.

@paullucas
Copy link
Contributor

Had to make a few changes to get the game example running on Arch Linux:

+++ b/core/SDLHelper.h
@@ -1,4 +1,4 @@
-#include <SDL.h>
+#include <SDL2/SDL.h>
--- a/core/sdl.carp
+++ b/core/sdl.carp
@@ -3,7 +3,8 @@
 (local-include "../core/SDLHelper.h")
 
 ;; Compiler flags
-(add-cflag "-I/usr/local/include/SDL2")
+(add-cflag "-I/usr/include/SDL2")

@eriksvedang
Copy link
Collaborator

OK, thanks. I'll make sure to fix this when there is support for conditional compilation based on the platform (should come soon).

@ephetic
Copy link

ephetic commented Oct 18, 2017

New REPL startup issue. If I start carp outside the repo directory, I get:

~ $ carp
Welcome to Carp 0.2.0
This is free software with ABSOLUTELY NO WARRANTY.
Evaluate (help) for more information.
carp: .//core/Macros.carp: openFile: does not exist (No such file or directory)
 ~ $ echo $CARP_DIR
/Users/bcleary/dev/carp
~ $ which carp
/Users/bcleary/.local/bin/carp

Works fine if started in ~/dev/carp

commit: 2dbcfac
Date: Wed Oct 18 13:02:44 2017 +0200

@eriksvedang
Copy link
Collaborator

Have you set a 'CARP_DIR' environment variable pointing to the root of the Carp directory?

@porky11
Copy link
Author

porky11 commented Oct 19, 2017

The first time I probably called an older version of Carp, i Installed some time ago.
Stack installs into ~/.local/bin/ and I used ~/bin/carp.
But the version was the same for both, so I thought, there is no difference.
I found out, it depends on in which directory I use carp.
When I'm outside of the Carp directory, where I built it, I get carp: .//core/Macros.carp: openFile: does not exist (No such file or directory).
Inside of the Carp directory it works as expected.

@ephetic
Copy link

ephetic commented Oct 19, 2017

CARP_DIR is set and it is calling the ~/.local/bin/carp just installed by Stack.

@eriksvedang
Copy link
Collaborator

I've now implemented the concept of search paths, perhaps this fixes the errors?

@ephetic
Copy link

ephetic commented Nov 20, 2017

Okay, looks like a shell issue. I tried it again in bash (with the export immediately before the command) and it does not report any errors. I must have set it wrong in my zsh profile.

Sorry about that.

@eriksvedang
Copy link
Collaborator

OK, no problem. Will close this then.

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

4 participants