Skip to content

Commit

Permalink
Bugfix for <with> return in FUNC specs
Browse files Browse the repository at this point in the history
The reorganization of the spec processing code to make it easier to
work with non-ANY-WORD!s (like QUOTED! and PATH!) broke the case where
the `<with>` that was used to suppress the creation of definitional
returns for that function.

Includes some stray `//`-comment cleanup.

Disables brew in old OS X, because it keeps hanging.
  • Loading branch information
hostilefork committed Jan 6, 2019
1 parent 10ccd8b commit 34aa979
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 55 deletions.
75 changes: 46 additions & 29 deletions .travis.yml
Expand Up @@ -83,9 +83,10 @@ matrix:
- STANDARD=c++11
- RIGOROUS=no
- STATIC=no # static linking switch not honored
- WITH_FFI="dynamic"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=dynamic
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS="ODBC + ZeroMQ +"
- BREW=yes
# libraries (ODBC, ZeroMQ...) added via brew in `install` step below

# OSX x64, release, clang++
Expand All @@ -112,9 +113,10 @@ matrix:
- STANDARD=c++14
- RIGOROUS=no
- STATIC=no # static linking switch not honored
- WITH_FFI="no" # no FFI in this build
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=no # no FFI in this build
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS="ODBC + ZeroMQ +"
- BREW=yes
# libraries (ODBC, ZeroMQ...) added via brew in `install` step below

# OSX x64, release, clang
Expand All @@ -133,10 +135,12 @@ matrix:
- STANDARD=c
- RIGOROUS=no
- STATIC=no
- WITH_FFI="no"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=no
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS="" # No ODBC or ZeroMQ in this build
# libraries (ODBC, ZeroMQ...) added via brew in `install` step below
- BREW=no
# The "Brew" OS X package installer appears to have stopped maintaining
# their service on this older system. It hangs. So just don't use it.

# Linux x86, release, gcc
#
Expand All @@ -152,7 +156,7 @@ matrix:
- STATIC=yes
- TCC=i386-tcc
- ARCH_CFLAGS=-m32
- WITH_FFI="dynamic"
- WITH_FFI=dynamic
- EXTENSIONS="" # 32-bit version does not have ODBC or ZeroMQ
addons:
apt:
Expand All @@ -179,8 +183,8 @@ matrix:
- RIGOROUS=yes
- STATIC=yes
- TCC=tcc
- WITH_FFI="dynamic"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=dynamic
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS="ODBC + ZeroMQ +"
- ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer-3.4
- ASAN_OPTIONS=symbolize=1
Expand Down Expand Up @@ -213,7 +217,7 @@ matrix:
- STANDARD=gnu99
- RIGOROUS=yes
- STATIC=yes
- WITH_FFI="dynamic"
- WITH_FFI=dynamic
- EXTENSIONS="" # no ODBC, ZeroMQ, FFI dependencies
addons:
apt:
Expand Down Expand Up @@ -248,8 +252,8 @@ matrix:
- STATIC=yes
- HOST=i686-w64-mingw32
- ARCH_CFLAGS=-m32
- WITH_FFI="dynamic"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=dynamic
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS="ODBC + Clipboard +"
addons:
apt:
Expand All @@ -275,8 +279,8 @@ matrix:
- TCC=x86_64-win32-tcc
- TCC_CPP_EXTRA_FLAGS='-I../external/tcc/win32/include -DPVAR=TVAR -DTVAR="extern __attribute__((dllimport))"'
- HOST=x86_64-w64-mingw32
- WITH_FFI="dynamic"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=dynamic
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS="ODBC + Clipboard +"
addons:
apt:
Expand Down Expand Up @@ -311,8 +315,8 @@ matrix:
- TCC=x86_64-win32-tcc
- TCC_CPP_EXTRA_FLAGS='-I../external/tcc/win32/include -DPVAR=TVAR -DTVAR="extern __attribute__((dllimport))"'
- HOST=x86_64-w64-mingw32
- WITH_FFI="dynamic"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=dynamic
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS="ODBC + Clipboard +"
addons:
apt:
Expand All @@ -335,8 +339,8 @@ matrix:
- RIGOROUS=yes
- STATIC=yes
- HOST=arm-eabi
- WITH_FFI="no"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=no
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS=""

# Android5, release, gcc
Expand All @@ -353,10 +357,10 @@ matrix:
- RIGOROUS=yes
- STATIC=yes
- HOST=arm-eabi
- WITH_FFI="no"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=no
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS=""
- TCC="arm-tcc"
- TCC=arm-tcc
- ARCH_CFLAGS="-DANDROID -DTCC_ARM_EABI -DTCC_ARM_VFP -DTCC_ARM_HARDFLOAT"
addons:
apt:
Expand All @@ -377,8 +381,8 @@ matrix:
- STANDARD=c
- RIGOROUS=no
- STATIC=no
- WITH_FFI="no"
- ODBC_REQUIRES_LTDL="no"
- WITH_FFI=no
- ODBC_REQUIRES_LTDL=no
- EXTENSIONS=- # requests inclusion of no extensions (default?)

# The install step occurs before the `script:` step runs. The language that
Expand Down Expand Up @@ -408,8 +412,7 @@ install:
- |
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
export REBOL_TOOL=./r3-osx-x64-8994d23
#
# The Travis OS X images have brew preinstalled, but get old and out of
# sync with the package database. This means brew has to update. It's
# supposed to do this automatically, but circa 2017 it broke in some
Expand All @@ -423,10 +426,24 @@ install:
#
# https://github.com/Homebrew/legacy-homebrew/issues/35662
#
brew update > /dev/null
if [[ "$BREW" == "yes" ]]; then # seems to not work on old OS X
brew update > /dev/null
brew install unixodbc # for ODBC extension
brew install zmq # for ZeroMQ extension
brew install unixodbc # for ODBC extension
brew install zmq # for ZeroMQ extension
export REBOL_TOOL=./r3-osx-x64-8994d23
else
# Brew was being installed even on minimal release builds, making it
# unnoticed that there was a .dylib dependency from the bootstrap
# release executable on ZeroMQ and ODBC. This old debug build was
# captured at the same version number as the bootstrap executables.
# Use it for now until the next capture for the old OS X.
#
wget http://hostilefork.com/media/shared/ren-c/r3-osx-x64-8994d23-debug
chmod +x ./r3-osx-x64-8994d23-debug
export REBOL_TOOL=$PWD/r3-osx-x64-8994d23-debug
fi
fi
- |
Expand Down
2 changes: 1 addition & 1 deletion make/tools/systems.r
Expand Up @@ -75,7 +75,7 @@ systems: [
; was: "Macintosh, FAT PPC, 68K"

0.2.04 osx-ppc/osx "osx-ppc"
#SGD #BEN #LLC #F64 <NCM> /HID /DYN %M ;originally targeted OS/X 10.2
#SGD #BEN #LLC #F64 <NCM> /HID /DYN %M ; originally targeted OS X 10.2

0.2.05 osx-x86/osx "osx-x86"
#SGD #LEN #LLC #NSER #F64 <NCM> <NPS> <ARC> /HID /ARC /DYN %M
Expand Down
37 changes: 21 additions & 16 deletions src/core/c-function.c
Expand Up @@ -82,7 +82,6 @@ REBARR *Make_Action_Words_Arr(REBACT *act, bool locals)
DEAD_END;
}


Init_Any_Word(DS_PUSH(), kind, VAL_PARAM_SPELLING(param));
if (quoted)
Quotify(DS_TOP, 1);
Expand Down Expand Up @@ -355,23 +354,11 @@ REBARR *Make_Paramlist_Managed_May_Fail(
REBSTR *spelling;
switch (VAL_TYPE(item)) {
case REB_WORD:
//
// Because FUNC does not do any locals gathering by default, the
// main purpose of <with> is for instructing it not to do the
// definitional returns. However, it also makes changing between
// FUNC and FUNCTION more fluid.
//
// !!! If you write something like `func [x <with> x] [...]` that
// should be sanity checked with an error...TBD.
//
if (mode == SPEC_MODE_WITH)
continue;
spelling = VAL_WORD_SPELLING(item);

assert(mode != SPEC_MODE_WITH); // should have continued...
pclass = (mode == SPEC_MODE_LOCAL)
? PARAM_CLASS_LOCAL
: PARAM_CLASS_NORMAL;
spelling = VAL_WORD_SPELLING(item);
break;

case REB_GET_WORD:
Expand Down Expand Up @@ -443,6 +430,24 @@ REBARR *Make_Paramlist_Managed_May_Fail(
}

REBSTR *canon = STR_CANON(spelling);
if (STR_SYMBOL(canon) == SYM_RETURN and pclass != PARAM_CLASS_LOCAL) {
//
// Cancel definitional return if any non-SET-WORD! uses the name
// RETURN when defining a FUNC.
//
flags &= ~(MKF_RETURN | MKF_FAKE_RETURN);
}

// Because FUNC does not do any locals gathering by default, the main
// purpose of tolerating <with> is for instructing it not to do the
// definitional returns. However, it also makes changing between
// FUNC and FUNCTION more fluid.
//
// !!! If you write something like `func [x <with> x] [...]` that
// should be sanity checked with an error...TBD.
//
if (mode == SPEC_MODE_WITH)
continue;

// In rhythm of TYPESET! BLOCK! TEXT! we want to be on a string spot
// at the time of the push of each new typeset.
Expand All @@ -463,7 +468,7 @@ REBARR *Make_Paramlist_Managed_May_Fail(
// Note there are currently two ways to get NULL: <opt> and <end>.
// If the typeset bits contain REB_MAX_NULLED, that indicates <opt>.
// But Is_Param_Endable() indicates <end>.

Init_Typeset(
DS_PUSH(),
(flags & MKF_ANY_VALUE)
Expand Down Expand Up @@ -492,7 +497,7 @@ REBARR *Make_Paramlist_Managed_May_Fail(
Init_Word(word, canon);
fail (Error_Dup_Vars_Raw(word)); // most dup checks done later
}
if (IS_SET_WORD(item))
if (pclass == PARAM_CLASS_LOCAL)
definitional_return_dsp = DSP; // RETURN: explicitly tolerated
else
flags &= ~(MKF_RETURN | MKF_FAKE_RETURN);
Expand Down
2 changes: 1 addition & 1 deletion src/include/reb-config.h
Expand Up @@ -197,7 +197,7 @@ Special internal defines used by RT, not Host-Kit developers:
#endif


//* Mac OS/X ********************************************************
//* Mac OS X ********************************************************

#ifdef TO_OSX_PPC
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/mezz/base-funcs.r
Expand Up @@ -352,7 +352,7 @@ redescribe: function [
fail [{PARAMETER-NOTES in META-OF is not a FRAME!} notes]
]

// !!! Getting error on equality test from expired frame...review
;; !!! Getting error on equality test from expired frame...review
comment [
if not equal? :value (action of notes) [
fail [{PARAMETER-NOTES in META-OF frame mismatch} notes]
Expand Down
10 changes: 5 additions & 5 deletions tests/context/collect-words.test.reb
@@ -1,26 +1,26 @@
; test suite for COLLECT-WORDS

( // base case
( ;; base case
words: collect-words [a a 'b c: [d] e/f 1 "" % ] []
empty? difference words [a b c]
)

( // /SET
( ;; /SET
words: collect-words/set [a 'b c: d:]
empty? difference words [c d]
)

( // /DEEP
( ;; /DEEP
words: collect-words/deep [a ['b [c:]]]
empty? difference words [a b c]
)

( // /IGNORE
( ;; /IGNORE
words: collect-words/ignore [a 'b c:] [c]
empty? difference words [a b]
)

( // /DEEP /SET /IGNORE
( ;; /DEEP /SET /IGNORE
words: collect-words/deep/set/ignore [a [b: [c:]]] [c]
empty? difference words [b]
)
Expand Down
2 changes: 1 addition & 1 deletion tests/control/every.test.reb
Expand Up @@ -40,7 +40,7 @@
did all [
false = every x [1 2 7] [
sum: me + x
if even? x [continue] // acts as `continue null`, get "falsified"
if even? x [continue] ;; acts as `continue null`, get "falsified"
true
]
10 = sum
Expand Down
2 changes: 1 addition & 1 deletion tests/functions/generate.test.reb
@@ -1,6 +1,6 @@
; GENERATE

( { GENERATE }
( { GENERATE }
{ Start with 1 then double while x < 100 }
{ => 1 2 4 8 16 32 64 }
for-each x sequence: generate [x: 1] [x < 100] [x: 2 * x] [t: x]
Expand Down

0 comments on commit 34aa979

Please sign in to comment.