From d2df3fe05824be32a6abd913d1aa1c05f50325e9 Mon Sep 17 00:00:00 2001 From: Scott Olsen Date: Thu, 24 Mar 2022 04:12:14 -0400 Subject: [PATCH 1/3] feat: support cons-last for arrays (#1402) --- src/Commands.hs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Commands.hs b/src/Commands.hs index c9c51b2e4..7da0db1e1 100644 --- a/src/Commands.hs +++ b/src/Commands.hs @@ -400,6 +400,8 @@ commandConsLast ctx x xs = pure $ case xs of XObj (Lst lst) i t -> (ctx, Right (XObj (Lst (lst ++ [x])) i t)) -- TODO: should they get their own i:s and t:s + XObj (Arr arr) i t -> + (ctx, Right (XObj (Arr (arr ++ [x])) i t)) _ -> evalError ctx "Applying 'cons-last' to non-list or empty list." (xobjInfo xs) commandAppend :: BinaryCommandCallback From bf6df6405c5ac29246f7d74a21b8e56c6d5c47d5 Mon Sep 17 00:00:00 2001 From: Scott Olsen Date: Mon, 28 Mar 2022 04:16:51 -0400 Subject: [PATCH 2/3] feat: add IO.fgetc (#1405) * feat: add feof and ferror These are C stdio functions that enable programmers to determine if a file read resulted in an error or EOF encounter. We can use these to power a definition of IO.fgetc, which is currently not defined. * feat: implement missing IO.fgetc IO defined a function, fgetc (distinct from IO.Raw.fgetc) which actually produced invalid code, since the name was not overridden and C does not define IO_fgetc. There was also a TODO to handle EOF conditions; so, I've implemented the function, checking for EOF and error conditions using the Raw stdio wrappers. IO.fgetc returns a Char in Success on success and an error string on failure. * refactor: distinguish EOF from errors in IO.fgetc We now report whether or not the error encountered in fgetc was EOF. Note that we don't yet report on the contents of other errors. --- core/IO.carp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/IO.carp b/core/IO.carp index 7ae957374..e62e07183 100644 --- a/core/IO.carp +++ b/core/IO.carp @@ -77,6 +77,8 @@ module are wrappers around the C standard library.") (register SEEK-END Int "SEEK_END") (doc ftell "gets the position indicator of a file (thin wrapper for the C standard library).") (register ftell (Fn [(Ptr FILE)] Int) "ftell") + (register feof (Fn [(Ptr FILE)] Bool) "feof") + (register ferror (Fn [(Ptr FILE)] Bool) "ferror") ) (doc println "prints a string ref to stdout, appends a newline.") @@ -90,7 +92,13 @@ module are wrappers around the C standard library.") (doc get-line "gets a line from stdin.") (register get-line (Fn [] String)) (doc fgetc "gets a character from a file pointer (thin wrapper for the C standard library).") - (register fgetc (Fn [(Ptr FILE)] Char)) ; TODO: check EOF handling (see carp_io.h)! + (defn fgetc [file] + (let [char (IO.Raw.fgetc file)] + (if (IO.Raw.feof file) + (Result.Error @"couldn't read char from file, EOF reached") + (if (IO.Raw.ferror file) + (Result.Error @"error while reading char from file") + (Result.Success (Char.from-int char)))))) (doc open-file "opens a file by name using a mode (e.g. [r]ead, [w]rite, [a]ppend), [rb] read binary...). See fopen() in the C standard library for a detailed description of valid parameters.") (defn open-file [filename mode] From fe91fb80ba98ae6e097ef7ad1a8c1a1cbea15e4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=A9v=C3=A9?= Date: Tue, 29 Mar 2022 08:19:59 +0100 Subject: [PATCH 3/3] ci: Re-enable Debug.sanitize on Windows (#1406) --- .github/workflows/windows.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 89716c916..670e20b8b 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -24,6 +24,11 @@ jobs: - name: Install Stack run: scoop install stack + - name: Install LLVM + run: | + scoop install llvm + echo "C:\Users\runneradmin\scoop\apps\llvm\current\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append + - uses: actions/cache@v1 name: Cache stack dependencies with: @@ -44,12 +49,6 @@ jobs: - name: Run Compiler Tests run: stack test - # Disabling sanitize-addresses because it fails with following error: - # https://github.com/actions/virtual-environments/issues/4978 - - name: Disable Debug.sanitize-addresses - shell: bash - run: find ./test ./examples -type f -name '*.carp' | xargs sed 's/^\((Debug.sanitize-addresses)\)/; \1/g' -i - - name: Run Carp Tests shell: bash run: ./scripts/run_carp_tests.sh --no_sdl