Skip to content

Commit

Permalink
fix #16356, deprecate juxtaposing hex literals
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Aug 17, 2017
1 parent a945af3 commit d46ae35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ Language changes
* In string and character literals, backslash `\` may no longer
precede unrecognized escape characters ([#22800]).

* Juxtaposing hex literals is deprecated, since it can lead to confusing
code such as `0xapi == 0xa * pi` ([#16356]).

* Declaring arguments as `x::ANY` to avoid specialization has been replaced
by `@nospecialize x`. ([#22666]).

Expand Down
19 changes: 13 additions & 6 deletions src/julia-parser.scm
Original file line number Diff line number Diff line change
Expand Up @@ -337,13 +337,20 @@
(write-char (read-char port) str)
(read-digs #t #f)
(disallow-dot))
(io.ungetc port c))))
(io.ungetc port c)))))
(if (and (char? c)
(or (and (or (eq? pred char-bin?) (eq? pred char-oct?))
(char-numeric? c))
(and (eq? pred char-hex?) (not is-hex-float-literal)
(identifier-start-char? c)
(syntax-deprecation port ;; remove after v0.7
(string (get-output-string str) c)
(string (get-output-string str) " * " c))
#f))) ;; remove after v0.7
;; disallow digits after binary or octal literals, e.g., 0b12
(if (and (or (eq? pred char-bin?) (eq? pred char-oct?))
(not (eof-object? c))
(char-numeric? c))
(error (string "invalid numeric constant \""
(get-output-string str) c "\"")))))
;; and disallow identifier chars after hex literals.
(error (string "invalid numeric constant \""
(get-output-string str) c "\""))))
(let* ((s (get-output-string str))
(r (cond ((eq? pred char-hex?) 16)
((eq? pred char-oct?) 8)
Expand Down

0 comments on commit d46ae35

Please sign in to comment.