1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 03:40:34 +02:00
Commit graph

2083 commits

Author SHA1 Message Date
Andy Wingo
315fabdfe7 Add support for immutable fields in core records
* module/ice-9/boot-9.scm (make-record-type): Allow (mutable NAME)
  or (immutable NAME) as a field name, and record field mutability in a
  bitfield.
  (record-modifier): Throw an error if the field isn't mutable.
* test-suite/tests/records.test ("records"): Add tests.
* doc/ref/api-data.texi (Records): Update.
2019-10-28 16:59:58 +01:00
Andy Wingo
f963bdf02d Rename final? record type flag; add support for opaque?
* module/ice-9/boot-9.scm (record-type-extensible?): Rename from
  record-type-final?, with the opposite sense.
  (record-type-opaque?): New accessor.
  (make-record-type): Change #:final? to #:extensible?, with the
  opposite meaning.  Add #:opaque? arg.
* test-suite/tests/records.test ("records"): Add opaque tests; update
  extensible tests.
* doc/ref/api-data.texi (Records): Update.
* module/srfi/srfi-35.scm (&condition, make-condition-type): Update for
  make-record-type API change.
2019-10-27 21:31:18 +01:00
Andy Wingo
7a8e314d31 Guile `make-record-type' supports non-generative definition
* module/ice-9/boot-9.scm (prefab-record-types): New definition.
  (make-record-type): Add #:uid keyword.
* test-suite/tests/records.test ("records"): Add tests.
* doc/ref/api-data.texi (Records): Document #:uid
2019-10-27 20:55:01 +01:00
Andy Wingo
958aa8b313 Change record type "flags" field to "properties"
* module/ice-9/boot-9.scm (record-type-properties): Rename from
  record-type-flags.
  (record-type-final?): New accessor.
  (make-record-type):
  (define-record-type):
* test-suite/tests/records.test ("records"): Adapt.
2019-10-27 20:03:51 +01:00
Andy Wingo
04615d3c20 Fix one remaining use of make-record-type with string type name
* test-suite/tests/gc.test ("weak-values versus records"): Fix to pass a
  symbol.
2019-10-23 14:45:36 +02:00
Andy Wingo
99a95383cf Rebase srfi-35 conditions on top of make-record-type
* module/srfi/srfi-35.scm: Import (ice-9 match), and remove now-unused
  srfi-1 import.
  (print-condition): Print more like records, as appears to be the
  intention.
  (&condition): Define using make-record-type.  Adapt all callers.
  Also, compound conditions are now a disjoint type, handled specially
  by condition-ref, condition?, and so on.
* test-suite/tests/srfi-35.test (v3): Fix an error in which a
  subcondition was initialized without initializers for all of its
  fields.
2019-10-23 14:42:35 +02:00
Andy Wingo
f116bd1009 make-record-type does more validation on the fields
* module/ice-9/boot-9.scm (make-record-type): Validate that the fields
  are a unique list of symbols.  Deprecate passing a string as a type
  name.
* module/system/base/syntax.scm (define-record): Update to pass a symbol
  as a type name.
* test-suite/tests/records.test (rtd-foo, rtd-fŏŏ, "records"): Adapt to
  make record types with symbol names.
2019-10-23 14:42:29 +02:00
Andy Wingo
f060f1a4e6 Record accessors respect subtyping
* module/ice-9/boot-9.scm (make-record-type): Don't allow subtyping of
  final types.
  (%record-type-error): Remove helper.
  (record-accessor, record-modifier): Use computed record type
  predicate, to allow for subtyping.
  (define-record-type): Adapt to %record-type-error going away; these
  types are final so no accessor adaptation is needed.
* test-suite/tests/records.test: Add tests.
* doc/ref/api-data.texi (Records): Update.
2019-10-22 16:22:48 +02:00
Andy Wingo
6205c2d7d4 Fix deprecated 1-arg `make-module' in tests
* test-suite/tests/modules.test ("circular imports"): Use nullary
  make-module.
2019-10-22 14:00:12 +02:00
Andy Wingo
1c88d51c22 Adapt ftw.test for pending test-suite changes
* test-suite/tests/ftw.test ("file-system-fold"): Check "standalone"
  instead of "vm".
2019-09-27 22:57:38 +02:00
Andy Wingo
4e89d0c061 Use "G_" as the conventional alias for gettext
Since the change in 2.2 noted in the NEWS as "Fix literal matching for
module-bound literals", defining `_' makes `syntax-rules' and `match'
fail to recognize `_' as the catch-all literal.  This change adapts the
recommendations to current practice in 2.2, as users have had to adapt
to this change.

* doc/ref/api-i18n.texi (Gettext Support): Update documentation.
* module/language/tree-il/analyze.scm (proc-ref?, gettext?): G_ is the
  conventional abbreviation, not _.
* test-suite/tests/tree-il.test: Adapt.
* module/ice-9/command-line.scm: Use G_ instead of _.
2019-09-12 21:50:35 +02:00
Andy Wingo
a2f5f9eda4 Fix bug in CSE auxiliary definitions
* module/language/cps/cse.scm (compute-equivalent-subexpressions): When
  CSE sees a definition like `(cons a b)', it will also record an
  "auxiliary definition" for `(car x)', where x is the variable defined
  by the cons, whereby calling `(car x)' can reduce to `a' if there is
  no intervening effect that clobbers the definitions.  However, when
  the successor of the cons is a control-flow join, then any variables
  defined there have multiple definitions.  It's incorrect to add the
  aux definition in that case.
* test-suite/tests/compiler.test ("cse auxiliary definitions"): New
  test.
2019-08-28 10:44:44 +02:00
Andy Wingo
2053592214 Allow mixed local definitions and expressions
This change to the expander allows mixed local definitions and
expressions.  The expansion turns:

  (let () (a) (define (b) 42) (b) (b))

into:

  (let ()
    (letrec* ((t0 (begin (a) (if #f #f)))
              (b (lambda () 42)))
      (b)))

Which is to say, expressions that precede definitions are expanded as
definitions of a temporary via (begin EXP (if #f #f)).

* module/ice-9/psyntax.scm (expand-body): Allow mixed definitions and
  expressions.
* module/ice-9/psyntax-pp.scm: Regenerate.
* test-suite/tests/syntax.test: Add a couple tests and update for new
  error messages.
2019-08-25 16:44:07 +02:00
Andy Wingo
6cf2fc1b9b Fix coverage test for top-level binding optimization
* test-suite/tests/coverage.test ("line-execution-counts"): Fix
  expectations for tail-call test.
2019-08-18 22:27:12 +02:00
Andy Wingo
25be9f9c31 Skip tests that don't work under letrectification
* test-suite/tests/srfi-64-test.scm: Skip a couple of tests that have
  unspecified result due to eq? being unspecified on procedures.
* module/language/tree-il/letrectify.scm (letrectify): Add a comment.
2019-08-18 22:27:12 +02:00
Andy Wingo
79a40cf717 Add "mod" field to tree-il toplevel ref, set, define
Add "mod" field to <toplevel-ref>, <toplevel-set>, and
<toplevel-define>, indicating the expander's idea of what the current
module is when a toplevel variable is accessed or created.  This will
help in later optimizations.

* libguile/expand.c (TOPLEVEL_REF, TOPLEVEL_SET, TOPLEVEL_DEFINE)
  (expand, expand_define, expand_set_x, convert_assignment):
* libguile/expand.h (SCM_EXPANDED_TOPLEVEL_REF_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_REF, SCM_EXPANDED_TOPLEVEL_SET_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_SET, SCM_EXPANDED_TOPLEVEL_DEFINE_FIELD_NAMES):
(SCM_MAKE_EXPANDED_TOPLEVEL_DEFINE):
* module/ice-9/compile-psyntax.scm (translate-literal-syntax-objects):
* module/ice-9/psyntax-pp.scm:
* module/ice-9/psyntax.scm:
* module/language/tree-il.scm:
* module/language/tree-il.scm (parse-tree-il, make-tree-il-folder):
(pre-post-order):
* module/language/tree-il/analyze.scm (goops-toplevel-definition):
(macro-use-before-definition-analysis, proc-ref?, format-analysis):
* module/language/tree-il/compile-cps.scm (convert):
* module/language/tree-il/debug.scm (verify-tree-il):
* module/language/tree-il/effects.scm (make-effects-analyzer):
* module/language/tree-il/fix-letrec.scm (free-variables):
* module/language/tree-il/peval.scm (peval):
* test-suite/tests/tree-il.test: Adapt uses.
2019-08-18 22:27:12 +02:00
Andy Wingo
e2f8ccc5ba Update peval tests for fix-letrec
* module/language/tree-il/fix-letrec.scm (fix-scc): Initial binding of
  letrec values is unspecified, not false.
* test-suite/tests/peval.test (pass-if-peval): Fix letrec before
  pevalling.  Update tests.  A couple got better, no regressions.
2019-08-13 15:07:57 +02:00
Andy Wingo
3869cdc59d Merge from stable-2.2 2019-08-02 15:34:28 +02:00
Andy Wingo
8ee6e766b8 Merge from stable-2.2 2019-08-02 15:30:13 +02:00
Andy Wingo
160a5c89bf Merge from stable-2.2 2019-08-02 15:21:34 +02:00
Andy Wingo
558dfa4568 Merge from stable-2.2 2019-08-02 14:59:38 +02:00
Andy Wingo
6a102205da Merge from stable-2.2 2019-08-02 14:32:35 +02:00
Andy Wingo
0a78d39b77 Merge from stable-2.2 2019-08-02 14:31:46 +02:00
Ludovic Courtès
ab2fd70ef1 'strftime' and 'strptime' honor the locale encoding.
Fixes <https://bugs.gnu.org/35920>.
Reported by Christopher Lam <christopher.lck@gmail.com>.

* libguile/stime.c (scm_strftime): Use 'scm_to_locale_stringn' instead
of 'scm_to_utf8_stringn'.
(scm_strptime): Likewise, and use 'scm_string_length' instead of
'u8_strnlen'.
* test-suite/tests/time.test ("strftime")["strftime passes wide
characters"]: Wrap body in 'with-locale'.
["strftime fr_FR.utf8", "strftime fr_FR.iso88591"]: New tests.
("strptime")["strftime fr_FR.utf8", "strftime fr_FR.iso88591"]: New
tests.
2019-06-30 21:31:36 +02:00
Ludovic Courtès
a152a67d38 tests: Add (web server) test.
* test-suite/tests/web-server.test: New file.
* test-suite/Makefile.am (SCM_TESTS): Add it.
2019-06-30 17:20:54 +02:00
Mark H Weaver
e1225d013e Revert "web: Add support for HTTP header continuation lines."
Fixes <https://bugs.gnu.org/36350>.

This reverts commit 73cde5ed72.
2019-06-24 11:33:13 -04:00
Mark H Weaver
73cde5ed72 web: Add support for HTTP header continuation lines.
* module/web/http.scm (spaces-and-tabs, space-or-tab?): New variables.
(read-header-line): After reading a header, if a space or tab follows,
read the continuation lines and join them.
* test-suite/tests/web-http.test: Add test.
2019-06-18 08:28:01 -04:00
Mark H Weaver
75f3ba7759 time.test: Use 'pass-if-equal' in more tests.
* test-suite/tests/time.test ("strftime"): Change some uses of 'pass-if'
to instead use 'pass-if-equal'.
2019-06-18 02:05:20 -04:00
Andy Wingo
8d46966052 Fix RTL tests for recent arity change
* test-suite/tests/rtl.test: Fix tests.
2019-06-07 17:10:32 +02:00
Timothy Sample
420c2632bb Make URI handling locale independent.
Fixes <https://bugs.gnu.org/35785>.

* module/web/uri.scm (digits, hex-digits, letters): New variables.
(ipv4-regexp, ipv6-regexp, domain-label-regexp, top-label-regexp,
userinfo-pat, host-pat, ipv6-host-pat, port-pat, scheme-pat): Explicitly
list each character instead of using character ranges.
* test-suite/tests/web-uri.test: Add corresponding tests.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
2019-06-04 21:24:02 +02:00
Ludovic Courtès
36ad1d24b3 'basename' correctly handles "/" and "//".
* libguile/filesys.c (scm_basename): Special-case "/" and "//".
* test-suite/tests/filesys.test ("basename"): New test prefix.
2019-06-04 21:24:02 +02:00
Mark H Weaver
bd50407d1f Strings, i18n: Limit the use of alloca to approximately 8 kilobytes.
* libguile/i18n.c (SCM_MAX_ALLOCA): New macro.
(SCM_STRING_TO_U32_BUF): Accept an additional variable to remember
whether we used malloc to allocate the buffer.  Use malloc if the
allocation size is greater than SCM_MAX_ALLOCA.
(SCM_CLEANUP_U32_BUF): New macro.
(compare_u32_strings, compare_u32_strings_ci, str_to_case): Adapt.
* libguile/strings.c (SCM_MAX_ALLOCA): New macro.
(normalize_str, unistring_escapes_to_r6rs_escapes): Use malloc if the
allocation size is greater than SCM_MAX_ALLOCA.
* test-suite/tests/i18n.test, test-suite/tests/strings.test: Add tests.
2019-05-23 17:51:36 +02:00
Mark H Weaver
c6692a4825 Avoid 'with-latin1-locale' in binary I/O tests.
* test-suite/tests/r6rs-ports.test ("put-bytevector [2 args]")
("put-bytevector [3 args]", "put-bytevector [4 args]"): Set the default
port encoding instead of setting the locale.
2019-05-23 17:48:55 +02:00
Michael Gran
d4fd9adcac Disable test for current value of setitimer on Cygwin
* test-suite/tests/signals.test ("current itimers are 0"): throws unresolved
    for cygwin
2019-05-23 17:32:17 +02:00
Michael Gran
42bc255224 Make locale monetary conversion tests be less strict on terminal whitespace
* test-suite/tests/i18n.test (monetary-amount->locale-string): modified
2019-05-23 17:32:15 +02:00
Mike Gran
a5df94e78c Fix binary output on files created by mkstemp!
Some operating systems require a O_BINARY flag.

* libguile/filesys.c (scm_i_mkstemp): Don't mask out O_BINARY flag
* test-suite/tests/posix.test ("binary mode honored"): new test
2019-05-23 17:30:33 +02:00
Mike Gran
9a7e66eceb Don't mutate read-only string in ports test
* test-suite/tests/ports.test ("valid wide mode string"): modified
2019-05-23 17:16:08 +02:00
Daniel Llorens
1b0fcddba5 Fix tests for SRFI-19 date->string ~N 2019-05-23 17:14:29 +02:00
Daniel Llorens
347ec3f088 Support ~N in SRFI-19 string->date
* module/srfi/srfi-19.scm (fractional-integer-reader,
  make-fractional-integer-reader): From reference implementation.
  (reader-directives): Handle #\N, from reference implementation.
* test-suite/tests/srfi-19: Add tests for string->date ~N.
* doc/ref/srfi-modules.texi (string->date): Add line for ~N.
2019-05-23 17:14:27 +02:00
Mark H Weaver
4f3aa81617 Update (ice-9 match) to include selected bug fixes from upstream.
Fixes <https://bugs.gnu.org/22925> and other bugs.

* module/ice-9/match.upstream.scm: Apply selected fixes from the
upstream match.scm in Chibi-Scheme.
* test-suite/tests/match.test.upstream: Add more tests from upstream.
2019-05-23 17:14:26 +02:00
Mark H Weaver
0389c59bd4 SRFI-19: Fix normalization of seconds and nanoseconds in time records.
Fixes <https://bugs.gnu.org/26162>.
Reported by Zefram <zefram@fysh.org>.

* module/srfi/srfi-19.scm (time-normalize!): Rewrite.
* test-suite/tests/srfi-19.test: Add tests.
2019-05-23 17:13:09 +02:00
Mark H Weaver
8361d59d1c SRFI-19: Add a few more tests.
This is a followup to commit a58c7abd72.

* test-suite/tests/srfi-19.test: Add tests for large positive years.
2019-05-23 17:13:07 +02:00
Mark H Weaver
db78033cc1 SRFI-19: Fix handling of negative years and negative julian days.
Fixes <https://bugs.gnu.org/21906>.
Mitigates <https://bugs.gnu.org/21903> and <https://bugs.gnu.org/21904>.
Reported by: Zefram <zefram@fysh.org>.

* module/srfi/srfi-19.scm (encode-julian-day-number)
(decode-julian-day-number, date-week-number): Use 'floor-quotient'
instead of 'quotient', and 'floor' instead of 'truncate', where
appropriate.
(time-utc->date): Ensure that the 'nanoseconds' field of the returned
date is non-negative.
(leap-year): Handle negative years properly, and reformulate the
computation.
(week-day): Handle negative years properly.  Use 'floor-quotient'
instead of 'quotient' where appropriate.
(directives): In the handler for '~Y' format escapes, improve the
handling of years outside of the range 0-9999.
(read-directives): Add a FIXME comment to fix the '~Y' reader to handle
years outside of the range 0-9999.
* test-suite/tests/srfi-19.test: Import (srfi srfi-1).  Use Guile's
modern keyword notation in the 'define-module' form.  Add more tests.
2019-05-23 17:13:05 +02:00
Mark H Weaver
e00563492a SRFI-19: Fix TAI->UTC conversions, leap second handling, etc.
Fixes <https://bugs.gnu.org/21911>.
Fixes <https://bugs.gnu.org/22034>.
Fixes <https://bugs.gnu.org/21902>.
Partially fixes <https://bugs.gnu.org/21904>.
Reported by Zefram <zefram@fysh.org>.

* doc/ref/srfi-modules.texi (SRFI-19 Introduction): Fix the definitions
of Julian Day and Modified Julian Day.  Give the correct full names of
UTC and TAI.
* module/srfi/srfi-19.scm: Import (srfi srfi-1).  Use modern Guile
keyword syntax in the 'define-module' form.
(leap-second-neg-delta): New procedure, derived from a similar procedure
in the latest upstream SRFI-19 reference implementation.
(priv:time-tai->time-utc!, time-tai->julian-day)
(time-monotonic->julian-day): Use 'leap-second-neg-delta'.
(local-tz-offset): Fix comment.
(leap-second?): Remove.
(tai-before-leap-second?): New procedure, derived from upstream SRFI-19.
(time-utc->date): Use 'define*' to handle the optional argument.  Remove
the leap second handling, following upstream SRFI-19.
(time-tai->date): Rewrite in terms of 'time-utc->date'.  Add special
leap second handling, following upstream SRFI-19.
(time-monotonic->date): Rewrite in terms of 'time-tai->date'.
(date->time-tai, date->time-monotonic): Add special leap second
handling, following upstream SRFI-19.
(directives): In the entry for the "~Y" escape in 'date->string', pad
the year field to 4 characters, following upstream SRFI-19.
* test-suite/tests/srfi-19.test: Add tests.
2019-05-23 17:13:03 +02:00
Mark H Weaver
0e750990dd Add tests for type inferencing for 'nil?' and 'null?' predicates.
These tests come from a fix for <https://bugs.gnu.org/33036>, which was
fixed already in the 2.9.x branch.

* test-suite/tests/compiler.test: Add tests.
2019-05-23 16:59:54 +02:00
Mark H Weaver
00973cbd2e In 'ash' and 'round-ash', handle right shift count of LONG_MIN.
Fixes <https://bugs.gnu.org/21901>.
Reported by Zefram <zefram@fysh.org>.

* libguile/numbers.c: Add another top-level 'verify' to ensure that
LONG_MIN is not a fixnum.
(scm_ash, scm_round_ash): Ensure that when the shift count is LONG_MIN,
it is not handled via the normal code path, to avoid signed overflow
when the shift count is negated.
* test-suite/tests/numbers.test: Add tests.
2019-05-23 16:09:45 +02:00
Mark H Weaver
e6100f64bb Fix 'round-ash' of negative integers by huge right shift counts.
This is a followup to commit 011aec7e24.

When rounding, right shifting a negative integer by a huge shift count
results in 0, not -1.

* libguile/numbers.c: Add top-level 'verify' to ensure that the
assumptions in 'scm_ash' and 'scm_round_ash' are valid.
(scm_round_ash): In the case that handles huge right shifts, require
that the shift count _exceeds_ the integer length, and return 0 instead
of -1.
* test-suite/tests/numbers.test: Adjust tests accordingly.
2019-05-23 16:09:41 +02:00
Mark H Weaver
e4c5f73f94 Gracefully handle huge shift counts in 'ash' and 'round-ash'.
Fixes <https://bugs.gnu.org/32644>.
Reported by Stefan Israelsson Tampe <stefan.itampe@gmail.com>.

The need for this arose because the type inferrer for 'ursh' sometimes
passes (- 1 (expt 2 64)) as the second argument to 'ash'.

* libguile/numbers.c (scm_ash, scm_round_ash): Gracefully handle several
cases where the shift count does not fit in a C 'long'.
* test-suite/tests/numbers.test: Add tests.
2019-05-23 16:08:12 +02:00
Mark H Weaver
5dcad70d99 Fix list validation of *list->bytevector procedures.
Fixes <https://bugs.gnu.org/32938>.
Reported by Josh Datko <jbd@cryptotronix.com>.

* libguile/validate.h (SCM_VALIDATE_LIST_COPYLEN)
(SCM_VALIDATE_NONEMPTYLIST_COPYLEN): Use '!=' instead of '>=' to
validate the result of 'scm_ilength' after it has been stored in
the user variable 'cvar'.
* test-suite/tests/bytevectors.test: Add tests.  Use '#:use-module'
instead of ':use-module' in 'define-module' form.
2019-05-23 16:01:13 +02:00
Ludovic Courtès
827e88b4b7 Define AT_SYMLINK_NOFOLLOW et al.
* libguile/posix.c (scm_init_posix): Define AT_SYMLINK_NOFOLLOW,
AT_SYMLINK_FOLLOW, AT_NO_AUTOMOUNT, and AT_EMPTY_PATH when available.
(scm_utime): Mention AT_SYMLINK_NOFOLLOW.
* doc/ref/posix.texi (File System): Update accordingly.
* test-suite/tests/posix.test ("utime")["AT_SYMLINK_NOFOLLOW"]: New test.
2019-05-23 15:43:28 +02:00