The plot objects get wrapped in arrays. You can do this
legend([f[1],g[1]],(L"f(x)", L"g(x)"), loc=2, fontsize="small")
or just put the labels in the plot calls (my preference):
f = plot([-1.0; 1.0], ones(2,1), "b", label=L"f(x)")
hold(true)
g = plot([-2.0; -1.0], [0.0; 2.0], "r", label=L"g(x)")
legend(loc=2, fontsize="small")