The present invention provides a heterocyclic compound represented by the following formula (I), which has a glucagon antagonistic action and is useful for the prophylaxis or treatment of diabetes and the like, a compound represented by
wherein ring A is an optionally substituted benzene ring and the like; Y is a nitrogen atom and the like; X is —O— and the like; R
4
is a hydrogen atom and the like; R
5
and R
6
are each independently a hydrogen atom and the like; R
1
is an optionally substituted hydrocarbon group and the like; R
2
is a hydrogen atom and the like; and R
3
is —(CH
2
)
3
—COOH and the like, or a salt thereof.