E08080: self assignment

Category: E08xxx Pre-IR checks (flow analysis) · Reported in phase: FULL_RESOLUTION · Classification: SELF_ASSIGNMENT · All error codes

What went wrong

You're assigning a variable to itself, which is pointless.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 318 (How does EK9 detect self-assignment and self-comparison?)

How to fix it

  1. Check variable names for typo
  2. Remove the self-assignment if unintended

Common causes

  • Typo (wrong variable name)
  • Copy/paste error
  • Confusion about assignment

See also

  • E08080: self-assignment (this error)
  • E08090: variable declared but unused

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E08080: self assignment

#!ek9
defines module error.e08080.bad

  defines function

    tidy()
      -> name as String
      <- rtn as String: name.trim()
      rtn: rtn

    copyOver()
      <- rtn as String: "draft"
      rtn :=: rtn

Fixed: Assign the value you meant - here, a different variable

#!ek9
defines module error.e08080.good

  defines function

    tidy()
      -> name as String
      <- rtn as String: name.trim()

    copyOver()
      -> source as String
      <- rtn as String: "draft"
      rtn :=: source

Questions and answers

These Q&A entries show E08080 and its fix:

Found a problem?

If EK9 reported E08080 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.