diff --git a/NEWS.md b/NEWS.md index 1c356a33be8b5..c6e83fbd6270f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -10,6 +10,9 @@ New language features Language changes ---------------- + * The syntax for parametric methods, `function f{T}(x::T)`, has been + changed to `function f(x::T) where {T}` ([#11310]). + * The syntax `1.+2` is deprecated, since it is ambiguous: it could mean either `1 .+ 2` (the current meaning) or `1. + 2` ([#19089]). diff --git a/src/ast.scm b/src/ast.scm index 0023531f04337..638c323f29cc5 100644 --- a/src/ast.scm +++ b/src/ast.scm @@ -96,6 +96,7 @@ (deparse-block (string (car e) " " (deparse (cadr e))) (block-stmts (caddr e)))) ((copyast) (deparse (cadr e))) + ((kw) (string (deparse (cadr e)) " = " (deparse (caddr e)))) (else (string e)))))) diff --git a/src/julia-syntax.scm b/src/julia-syntax.scm index b77fdb6ed096d..bae08acb22efe 100644 --- a/src/julia-syntax.scm +++ b/src/julia-syntax.scm @@ -810,14 +810,16 @@ (sig (car temp)) (params (cdr temp))) (if (pair? params) - (let* ((lnos (filter (lambda (e) (and (pair? e) (eq? (car e) 'line))) - body)) - (lno (if (null? lnos) '() (car lnos)))) - (syntax-deprecation #f - (string "inner constructor " name "(...)" (linenode-string lno)) - (deparse `(where (call (curly ,name ,@params) ...) ,@params))))) + (syntax-deprecation #f + (string "inner constructor " name "(...)" (linenode-string (function-body-lineno body))) + (deparse `(where (call (curly ,name ,@params) ...) ,@params)))) `(,keyword ,sig ,(ctor-body body params))))))) +(define (function-body-lineno body) + (let ((lnos (filter (lambda (e) (and (pair? e) (eq? (car e) 'line))) + body))) + (if (null? lnos) '() (car lnos)))) + ;; rewrite calls to `new( ... )` to `new` expressions on the appropriate ;; type, determined by the containing constructor definition. (define (rewrite-ctor ctor Tname params bounds field-names field-types) @@ -1062,6 +1064,11 @@ (eq? (caar argl) 'parameters)))))) (name (if (or (decl? name) (and (pair? name) (eq? (car name) 'curly))) #f name))) + (if has-sp + (syntax-deprecation #f + (string "static parameter syntax " (deparse (cadr e)) + (linenode-string (function-body-lineno body))) + (deparse `(where (call ,name ,@(cdr argl)) ,@(map car sparams))))) (expand-forms (method-def-expr name sparams argl body isstaged rett)))) (else