Misplaced assignment statement

my code is giving me an error: LoadError: syntax: misplaced assignment statement in “[T = BigInt]”
what does this error mean?

Welcome!
What are trying to do? This does not look like valid Julia. You can post your code here in triple backtick quotes. Someone will be happy to look it over…

1 Like

I’m trying to use the setprecision function, exactly as described in the docs:
setprecision([T=BigInt,], 512, 2)
just with different values for the precision and base

Try setprecision(BigInt, 512, 2). The square brackets indicate optional argument in the documentation.

5 Likes

The error means the assignment T = BigInt is incorrectly placed. In Julia, assignments like this are not allowed within type parameter brackets.

Just to be clear, that’s not valid syntax for a method definition header, though it’s certainly based on it. A leading optional argument isn’t possible to parse, it’s a docstring shorthand for separately written method definitions. Also note that method definition headers do not mirror method calls exactly. For example, you could define methods by writing foo(a=1) = a, but the call foo(a=1) does not work.

For another example of documentation deviating from Julia syntax, map methods for Arrays are documented with the signature:

 map(f, A::AbstractArray...) -> N-array

N-array doesn’t mean anything in Julia, and -> is not used for types of return values in Julia source code.