Formatted Docstring Duplicated when Overloading Function Definition in Seperate Cells

I think I may have found a bug, but I’ve never made a issue on an open source project before, and I wanted a sanity check to see if it is worth creating.

Minimum Working Example:

Cell 1:

"Test String"
function somefunc1(x,y)
	println(x, y)
end

Cell 2:

function somefunc1(x)
	somefunc(x, x)
end

Then repeatedly running cell 1 results in a duplicated docstring. It also occurs if the docstring is on the second function.

I was writing a function that built a matrix depending on a passed x and y dimension, but I wanted a version that could take a single dimension, and build a square matrix, and stumbled across this bug.

This can be written in alternative ways to avoid the duplication:

begin
	function somefunc2(x)
		somefunc2(x,x)
	end
	"Test String"
	function somefunc2(x,y)
		println(x, y)
	end
end

or

"Test String"
function somefunc3(x, y=x)
	println(x,y)
end

In testing out these combinations, I realized that the second option using the default parameter is far more succinct than my original method that resulted in the docstring duplication, so I could just change it and not have a problem.

However, even if the two cell function definition is not the best way to implement the function, the docstring shouldn’t get duplicated. There have been previous issues with docstring duplication that got fixed in March, for example.

This is my first real interaction with the Julia community besides just reading posts, so I wanted to be careful and get some of your opinions. Should this be opened as an issue in Pluto.jl?

Hello! First of all, welcome to the Julia Community!

I think the bug you encountered is definitively worth opening an issue for. It is also very nice that you have investigated the exact conditions for the bug to happen and provide a minimum example to reproduce the issue. You already searched for duplicate issues and indeed similar issues have been closed recently but your case seems to not be covered by the fix so it can be great to open a new issue referencing the previous closed ones to track this different behavior.

1 Like