Erase function not working in class

The erase function of my class below doesn’t seem to work. It worked fine before I moved everything into a class.
I can’t find what’s wrong.

Map = class()

function Map:init(x,y,w,h)
    self.img = image(w,h)
    self.x = x
    self.y = y
end

function Map:draw()
    sprite(self.img, self.x, self.y)
end

function Map:erase(xy, radius)
    --print(self.img)
    col = color(0, 0, 0, 0)
    for y=-radius, radius do
        for x=-radius, radius do
            if x*x+y*y <= radius*radius then
                self.img:set(xy.x+x, xy.y+y, col)
            end
        end
    end
end

function Map:makeTerrain(wallCol, edgeCol)
    setContext(self.img)
    
    local walls = {}
    for i=1, 50 do
        table.insert(walls, 
        {x=math.random()*WIDTH, y=math.random()*HEIGHT, rad=math.random()*300})
    end
    
    fill(edgeCol)
    for i=1, #walls do
        ellipse(walls[i].x, walls[i].y, walls[i].rad+5)
    end
    fill(wallCol)
    for i=1, #walls do
        ellipse(walls[i].x, walls[i].y, walls[i].rad)
    end
    setContext()
end

not sure what the erase function is meant to do, but if it’s just clearing the image, you can try this:

setContext(self.img)
background(0,0)
setContext()

You may know this already, but just checking - make sure that when you call it, you use a colon and not a full stop, ie

m=map()
m:erase() --correct
m.erase() --incorrect

@Kirl Your erase function does work. Run this and tap the screen to call erase. I added an image in Map:init to have something to erase.

function setup()
    m=Map(WIDTH/2,HEIGHT/2,50,50)
end

function draw()
    background(0)
    m:draw()
end

function touched(t)
    if t.state==BEGAN then
        m:erase(vec2(200,200),100)
    end
end

Map = class()

function Map:init(x,y,w,h)
    --self.img = image(w,h)
    self.img = readImage("Cargo Bot:Codea Icon")
    self.x = x
    self.y = y
end

function Map:draw()
    sprite(self.img, self.x, self.y)
end

function Map:erase(xy, radius)
    --print(self.img)
    col = color(0, 0, 0, 0)
    for y=-radius, radius do
        for x=-radius, radius do
            if x*x+y*y <= radius*radius then
                self.img:set(xy.x+x, xy.y+y, col)
            end
        end
    end
end

function Map:makeTerrain(wallCol, edgeCol)
    setContext(self.img)

    local walls = {}
    for i=1, 50 do
        table.insert(walls, 
        {x=math.random()*WIDTH, y=math.random()*HEIGHT, rad=math.random()*300})
    end

    fill(edgeCol)
    for i=1, #walls do
        ellipse(walls[i].x, walls[i].y, walls[i].rad+5)
    end
    fill(wallCol)
    for i=1, #walls do
        ellipse(walls[i].x, walls[i].y, walls[i].rad)
    end
    setContext()
end

I found the problem, i didn’t call background() at the beginning of the draw function to clear the screen before drawing the new image.

Thanks for the suggestions though, they made me go over my code for the umpth time. =)