# Misplaced assignment statement

**URL:** https://discourse.julialang.org/t/misplaced-assignment-statement/123194
**Category:** New to Julia
**Tags:** question
**Created:** [November 28, 2024, 2:11am UTC](https://discourse.julialang.org/t/misplaced-assignment-statement/123194 "2024-11-28T02:11:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![engineer-in-a-box](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/engineer-in-a-box/32/213520_2.png) [@engineer-in-a-box](https://discourse.julialang.org/u/engineer-in-a-box)
#### Post date: [November 28, 2024, 2:11am UTC](https://discourse.julialang.org/t/misplaced-assignment-statement/123194/1 "2024-11-28T02:11:14Z")

</div>

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

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [November 28, 2024, 2:29am UTC](https://discourse.julialang.org/t/misplaced-assignment-statement/123194/2 "2024-11-28T02:29:58Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![engineer-in-a-box](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/engineer-in-a-box/32/213520_2.png) [@engineer-in-a-box](https://discourse.julialang.org/u/engineer-in-a-box)
#### Post date: [November 28, 2024, 2:48am UTC](https://discourse.julialang.org/t/misplaced-assignment-statement/123194/3 "2024-11-28T02:48:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![PetrKryslUCSD](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/petrkryslucsd/32/215825_2.png) [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)
#### Post date: [November 28, 2024, 2:56am UTC](https://discourse.julialang.org/t/misplaced-assignment-statement/123194/4 "2024-11-28T02:56:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![johnbarry1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/johnbarry1/32/213818_2.png) [@johnbarry1](https://discourse.julialang.org/u/johnbarry1)
#### Post date: [November 29, 2024, 10:04am UTC](https://discourse.julialang.org/t/misplaced-assignment-statement/123194/5 "2024-11-29T10:04:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)
#### Post date: [November 29, 2024, 11:59am UTC](https://discourse.julialang.org/t/misplaced-assignment-statement/123194/6 "2024-11-29T11:59:48Z")

</div>

> [@engineer-in-a-box](#):
>
> setprecision([T=BigInt,], 512, 2)

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 `Array`s are documented with the signature:

```julia
 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.
