Skip to content

Commit

Permalink
don't give a parse error for (x)ᵀ (JuliaLang#24567)
Browse files Browse the repository at this point in the history
The operator suffix feature unintentionally disallowed using identifiers
in certain contexts if they happened to consist entirely of valid
operator suffix characters.
  • Loading branch information
JeffBezanson authored Nov 13, 2017
1 parent a282b5f commit 4d5ed2e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/flisp/julia_extensions.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ value_t fl_julia_strip_op_suffix(fl_context_t *fl_ctx, value_t *args, uint32_t n
i = j;
}
if (!op[i]) return args[0]; // no suffix to strip
if (!i) lerror(fl_ctx, symbol(fl_ctx, "error"), "invalid operator");
if (!i) return args[0]; // only suffix chars --- might still be a valid identifier
char *opnew = strncpy((char*)malloc(i+1), op, i);
opnew[i] = 0;
value_t opnew_symbol = symbol(fl_ctx, opnew);
Expand Down
2 changes: 2 additions & 0 deletions test/syntax.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1037,6 +1037,8 @@ for bad in ('=', '$', ':', "||", "&&", "->", "<:")
end
@test Base.operator_precedence(:+̂) == Base.operator_precedence(:+)

@test Meta.parse("(x)ᵀ") == Expr(:call, :*, :x, :ᵀ)

# issue #19351
# adding return type decl should not affect parse of function body
@test :(t(abc) = 3).args[2] == :(t(abc)::Int = 3).args[2]
Expand Down

0 comments on commit 4d5ed2e

Please sign in to comment.