by AlchemistCamp · 3y ago · 0 comments
After typing in nothing more than, "defmodule Fibonacci do", Copilot emitted the entire module from the code on my site here: https://alchemist.camp/episodes/elixir-tdd-ex_unit
The function names and documentation strings were identical. Also, the site isn't under a GPL, just a standard copyright. That said, I'm curious to learn if others see the same behavior. It's possible I once opened that file locally with Copilot installed and that my own computer was its source.
defmodule Fibonnaci do
def fibonnaci(0), do: 0
def fibonnaci(1), do: 1
def fibonnaci(n), do: fibonnaci(n - 1) + fibonnaci(n - 2)
end
Which seems fine I guess (I don't know the language), but doesn't even have comments. I prefer my files with comments. After forcing the point, I got this: defmodule Fibonnaci do
@moduledoc """
Documentation for Fibonnaci.
"""
@doc """
Calculates the nth Fibonnaci number
"""
def fibonnaci(n) when n < 0, do: nil
def fibonnaci(0), do: 0
def fibonnaci(1), do: 1
def fibonnaci(n), do: fibonnaci(n - 1) + fibonnaci(n - 2)
end
In which I prompted the AI with everything up to (and including) @doc. So I figure it was picking it up from your computer, somehow.EDIT: I then noticed the typo, tried it with fibonacci.ex, and got the same result.
One other possible cause I thought of is that I did have the test file in my mix project already. If copilot looks at the corresponding file in the test dir, then it would not be a coincidence at all that all function names were identical or that it wrote a tail recursive solution instead of the naive solution that would have failed the final test.
def fib(0), do: 0
def fib(1), do: 1
def fib(n), do: fib(n - 1) + fib(n - 2)
end